diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index fcb414c7..dcdbf674 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -640,7 +640,13 @@ namespace AyaNova.Biz i.UserOptions.EmailAddress = j["EmailAddress"].Value(); //UI colour - i.UserOptions.UiColor = j["ScheduleBackColor"].Value(); + //TODO: this needs to be switched to a web friendly value + /* + Hexadecimal notation: #RGB[A] + R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. + */ + throw new ArgumentOutOfRangeException("UserBiz::ImportV7Async - UI color needs to be pre-converted in DataDump to RGB values"); + //i.UserOptions.UiColor = j["ScheduleBackColor"].Value(); //Set unusable random login credentials diff --git a/server/AyaNova/biz/UserOptionsBiz.cs b/server/AyaNova/biz/UserOptionsBiz.cs index 054d3c27..034b17d9 100644 --- a/server/AyaNova/biz/UserOptionsBiz.cs +++ b/server/AyaNova/biz/UserOptionsBiz.cs @@ -101,6 +101,11 @@ namespace AyaNova.Biz if (inObj.UserId == 0) AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId"); + if (inObj.UiColor.Length > 12) + { + AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "UiColor", "UiColor must be HEX color value"); + } + //LOOKAT:Validate email address is legitimate (I put the EMailAddress attribute on the field in the model so I think it might validate) return; diff --git a/server/AyaNova/models/UserOptions.cs b/server/AyaNova/models/UserOptions.cs index 727ded6c..87353bf1 100644 --- a/server/AyaNova/models/UserOptions.cs +++ b/server/AyaNova/models/UserOptions.cs @@ -12,14 +12,13 @@ namespace AyaNova.Models //------------- [EmailAddress] public string EmailAddress { get; set; } - /// - /// As of today Dec 10 2018 all time zones in the world are either on the hour, half hour or 45 minute mark from utc so - /// keeping this value as decimal hours for back compatibility with v7 and easier for user to enter - /// 8.5 for 8:30 time difference or 12.75 for 12:45 time differnce for example - /// - /// - - public int UiColor { get; set; } + + /* + Hexadecimal notation: #RGB[A] + R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. + */ + [MaxLength(12)] + public string UiColor { get; set; } //browser forced overrides public string LanguageOverride { get; set; } @@ -40,7 +39,7 @@ namespace AyaNova.Models { CurrencyName = "USD"; Hour12 = true; - UiColor = 0; + UiColor = "#000000";//black is the default } } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index f7068483..47cb8641 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -177,7 +177,7 @@ namespace AyaNova.Util //Add user options table await ExecQueryAsync("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, " + - "userid bigint not null, languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor int not null default 0)"); + "userid bigint not null, languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor varchar(12) not null default '#000000')"); //Prime the db with the default MANAGER account diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index eb564f69..85795c3a 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -593,6 +593,7 @@ namespace AyaNova.Util u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com"); u.UserOptions.Hour12 = true; u.UserOptions.CurrencyName = "USD"; + u.UserOptions.UiColor= Fake.Internet.Color(); @@ -624,6 +625,7 @@ namespace AyaNova.Util // WidgetBiz biz = WidgetBiz.GetBiz(ServiceProviderProvider.DBContext); var f = new Bogus.Faker(); + //RANDOM ROLES Array values = Enum.GetValues(typeof(UserType));