This commit is contained in:
@@ -12,8 +12,8 @@ Remove OwnerId
|
||||
- DONE Widget
|
||||
- DONE Locale
|
||||
- DONE User
|
||||
- UserOptions remove but also has a bit below
|
||||
- ValidateJsonPatch
|
||||
- DONE UserOptions remove but also has a bit below
|
||||
- DONE ValidateJsonPatch
|
||||
- FileAttachment
|
||||
|
||||
- Rename OwnerId to UserId for those objects that require it still
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace AyaNova.Biz
|
||||
u.Login = "manager";
|
||||
u.Password = Hasher.hash(u.Salt, "l3tm3in");
|
||||
u.Roles = AuthorizationRoles.AnyRole;//AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
|
||||
u.OwnerId = 1;
|
||||
|
||||
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
|
||||
u.UserType = UserType.Administrator;
|
||||
u.UserOptions = new UserOptions(1);
|
||||
u.UserOptions = new UserOptions();
|
||||
ct.User.Add(u);
|
||||
ct.SaveChanges();
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace AyaNova.Biz
|
||||
|
||||
Locale l = new Locale();
|
||||
l.Name = localeCode;
|
||||
l.OwnerId = 1;
|
||||
|
||||
l.Stock = true;
|
||||
l.CjkIndex = false;
|
||||
|
||||
|
||||
@@ -761,7 +761,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//User options
|
||||
i.UserOptions = new UserOptions(i.OwnerId);
|
||||
i.UserOptions = new UserOptions();
|
||||
|
||||
//TimeZone Offset
|
||||
//Note: can be null value if not set so need to check for that here specially
|
||||
|
||||
@@ -45,12 +45,10 @@ namespace AyaNova.Biz
|
||||
//put
|
||||
internal bool Put(UserOptions dbObj, UserOptions inObj)
|
||||
{
|
||||
//preserve the owner ID if none was specified
|
||||
if (inObj.OwnerId == 0)
|
||||
inObj.OwnerId = dbObj.OwnerId;
|
||||
|
||||
|
||||
//Replace the db object with the PUT object
|
||||
CopyObject.Copy(inObj, dbObj, "Id, UserId, OwnerId");
|
||||
CopyObject.Copy(inObj, dbObj, "Id, UserId");
|
||||
//Set "original" value of concurrency token to input token
|
||||
//this will allow EF to check it out
|
||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
|
||||
@@ -98,11 +96,8 @@ namespace AyaNova.Biz
|
||||
//UserOptions is never new, it's created with the User object so were only here for an edit
|
||||
|
||||
|
||||
//OwnerId required
|
||||
if (inObj.OwnerId == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId");
|
||||
|
||||
//OwnerId required
|
||||
//UserId required
|
||||
if (inObj.UserId == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId");
|
||||
|
||||
|
||||
@@ -37,12 +37,7 @@ namespace AyaNova.Biz
|
||||
IsValid = false;
|
||||
}
|
||||
|
||||
if (objectPatch.Operations.Any(m => m.path == "/ownerid"))
|
||||
{
|
||||
biz.AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "OwnerId");
|
||||
IsValid = false;
|
||||
}
|
||||
|
||||
|
||||
if (objectPatch.Operations.Any(m => m.path == "/serial"))
|
||||
{
|
||||
biz.AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Serial");
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace AyaNova.Biz
|
||||
internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
|
||||
{
|
||||
//Validate Patch is allowed
|
||||
//Note: Id, OwnerId and Serial are all checked for and disallowed in the validate code by default
|
||||
//Note: Id and Serial are all checked for and disallowed in the validate code by default
|
||||
if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
|
||||
|
||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
||||
|
||||
@@ -10,8 +10,7 @@ namespace AyaNova.Models
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
|
||||
|
||||
//-------------
|
||||
[EmailAddress]
|
||||
@@ -33,12 +32,10 @@ namespace AyaNova.Models
|
||||
public long UserId { get; set; }//will be auto-set by EF due to relationship defined
|
||||
|
||||
|
||||
public UserOptions(long ownerId)
|
||||
public UserOptions()
|
||||
{
|
||||
|
||||
TimeZoneOffset = 0;
|
||||
UiColor = 0;
|
||||
OwnerId = ownerId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace AyaNova.Util
|
||||
exec("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);");
|
||||
|
||||
//Add user options table
|
||||
exec("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, " +
|
||||
exec("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, " +
|
||||
"userid bigint not null, timezoneoffset decimal(19,5) not null default 0, emailaddress text, uicolor int not null default 0)");
|
||||
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
User u = new User();
|
||||
u.Active = active;
|
||||
u.OwnerId = 1;
|
||||
|
||||
var p = new Bogus.Person();
|
||||
u.Name = Uniquify(p.FullName);
|
||||
if (login != null)
|
||||
@@ -435,7 +435,7 @@ namespace AyaNova.Util
|
||||
//TODO: After have USER and HEADOFFICE and VENDOR, if usertype is subcontractor or client or headoffice it needs to set a corresponding user's parent org record id to go with it
|
||||
u.Tags = RandomTags(Fake);
|
||||
//Children and relations
|
||||
u.UserOptions = new UserOptions(1);
|
||||
u.UserOptions = new UserOptions();
|
||||
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
|
||||
u.UserOptions.TimeZoneOffset = timeZoneOffset;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user