This commit is contained in:
2019-05-20 19:09:08 +00:00
parent 7d11399574
commit dd2b227d88
9 changed files with 16 additions and 29 deletions

View File

@@ -12,8 +12,8 @@ Remove OwnerId
- DONE Widget - DONE Widget
- DONE Locale - DONE Locale
- DONE User - DONE User
- UserOptions remove but also has a bit below - DONE UserOptions remove but also has a bit below
- ValidateJsonPatch - DONE ValidateJsonPatch
- FileAttachment - FileAttachment
- Rename OwnerId to UserId for those objects that require it still - Rename OwnerId to UserId for those objects that require it still

View File

@@ -27,10 +27,10 @@ namespace AyaNova.Biz
u.Login = "manager"; u.Login = "manager";
u.Password = Hasher.hash(u.Salt, "l3tm3in"); u.Password = Hasher.hash(u.Salt, "l3tm3in");
u.Roles = AuthorizationRoles.AnyRole;//AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull; 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.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
u.UserType = UserType.Administrator; u.UserType = UserType.Administrator;
u.UserOptions = new UserOptions(1); u.UserOptions = new UserOptions();
ct.User.Add(u); ct.User.Add(u);
ct.SaveChanges(); ct.SaveChanges();
@@ -78,7 +78,7 @@ namespace AyaNova.Biz
Locale l = new Locale(); Locale l = new Locale();
l.Name = localeCode; l.Name = localeCode;
l.OwnerId = 1;
l.Stock = true; l.Stock = true;
l.CjkIndex = false; l.CjkIndex = false;

View File

@@ -761,7 +761,7 @@ namespace AyaNova.Biz
} }
//User options //User options
i.UserOptions = new UserOptions(i.OwnerId); i.UserOptions = new UserOptions();
//TimeZone Offset //TimeZone Offset
//Note: can be null value if not set so need to check for that here specially //Note: can be null value if not set so need to check for that here specially

View File

@@ -45,12 +45,10 @@ namespace AyaNova.Biz
//put //put
internal bool Put(UserOptions dbObj, UserOptions inObj) 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 //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 //Set "original" value of concurrency token to input token
//this will allow EF to check it out //this will allow EF to check it out
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken; 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 //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) if (inObj.UserId == 0)
AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId"); AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId");

View File

@@ -37,12 +37,7 @@ namespace AyaNova.Biz
IsValid = false; 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")) if (objectPatch.Operations.Any(m => m.path == "/serial"))
{ {
biz.AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Serial"); biz.AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Serial");

View File

@@ -170,7 +170,7 @@ namespace AyaNova.Biz
internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken) internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
{ {
//Validate Patch is allowed //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; if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
//make a snapshot of the original for validation but update the original to preserve workflow //make a snapshot of the original for validation but update the original to preserve workflow

View File

@@ -10,8 +10,7 @@ namespace AyaNova.Models
{ {
public long Id { get; set; } public long Id { get; set; }
public uint ConcurrencyToken { get; set; } public uint ConcurrencyToken { get; set; }
[Required]
public long OwnerId { get; set; }
//------------- //-------------
[EmailAddress] [EmailAddress]
@@ -33,12 +32,10 @@ namespace AyaNova.Models
public long UserId { get; set; }//will be auto-set by EF due to relationship defined public long UserId { get; set; }//will be auto-set by EF due to relationship defined
public UserOptions(long ownerId) public UserOptions()
{ {
TimeZoneOffset = 0; TimeZoneOffset = 0;
UiColor = 0; UiColor = 0;
OwnerId = ownerId;
} }
} }

View File

@@ -173,7 +173,7 @@ namespace AyaNova.Util
exec("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);"); exec("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);");
//Add user options table //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)"); "userid bigint not null, timezoneoffset decimal(19,5) not null default 0, emailaddress text, uicolor int not null default 0)");

View File

@@ -414,7 +414,7 @@ namespace AyaNova.Util
{ {
User u = new User(); User u = new User();
u.Active = active; u.Active = active;
u.OwnerId = 1;
var p = new Bogus.Person(); var p = new Bogus.Person();
u.Name = Uniquify(p.FullName); u.Name = Uniquify(p.FullName);
if (login != null) 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 //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); u.Tags = RandomTags(Fake);
//Children and relations //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.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
u.UserOptions.TimeZoneOffset = timeZoneOffset; u.UserOptions.TimeZoneOffset = timeZoneOffset;