From dd2b227d88980c29a7f4f5f1a9c2cdf0785608c8 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 May 2019 19:09:08 +0000 Subject: [PATCH] --- devdocs/todo.txt | 4 ++-- server/AyaNova/biz/PrimeData.cs | 6 +++--- server/AyaNova/biz/UserBiz.cs | 2 +- server/AyaNova/biz/UserOptionsBiz.cs | 11 +++-------- server/AyaNova/biz/ValidateJsonPatch.cs | 7 +------ server/AyaNova/biz/WidgetBiz.cs | 2 +- server/AyaNova/models/UserOptions.cs | 7 ++----- server/AyaNova/util/AySchema.cs | 2 +- server/AyaNova/util/Seeder.cs | 4 ++-- 9 files changed, 16 insertions(+), 29 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index c61092d8..0da9e800 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -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 diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs index ce736361..f39de588 100644 --- a/server/AyaNova/biz/PrimeData.cs +++ b/server/AyaNova/biz/PrimeData.cs @@ -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; diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index d461b75b..8ab41de2 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -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 diff --git a/server/AyaNova/biz/UserOptionsBiz.cs b/server/AyaNova/biz/UserOptionsBiz.cs index dd3066bc..a8c83ec8 100644 --- a/server/AyaNova/biz/UserOptionsBiz.cs +++ b/server/AyaNova/biz/UserOptionsBiz.cs @@ -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"); diff --git a/server/AyaNova/biz/ValidateJsonPatch.cs b/server/AyaNova/biz/ValidateJsonPatch.cs index c6c29eb2..6258c083 100644 --- a/server/AyaNova/biz/ValidateJsonPatch.cs +++ b/server/AyaNova/biz/ValidateJsonPatch.cs @@ -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"); diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index aeb4298a..639f398b 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -170,7 +170,7 @@ namespace AyaNova.Biz internal bool Patch(Widget dbObj, JsonPatchDocument 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.Validate(this, objectPatch)) return false; //make a snapshot of the original for validation but update the original to preserve workflow diff --git a/server/AyaNova/models/UserOptions.cs b/server/AyaNova/models/UserOptions.cs index e564448f..7875dd5d 100644 --- a/server/AyaNova/models/UserOptions.cs +++ b/server/AyaNova/models/UserOptions.cs @@ -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; } } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 9a9be905..6c783322 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -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)"); diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index b8a4a651..264fd6e6 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -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;