diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 1adc9dc4..7cdfc856 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -31,6 +31,7 @@ namespace AyaNova.Util { bool LogJob = JobId != Guid.Empty; + ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder"); ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState)); @@ -54,12 +55,27 @@ namespace AyaNova.Util throw new System.NotSupportedException(msg); } + //validate timezone offset + if (timeZoneOffset > 14 || timeZoneOffset < (-12)) + { + var msg = $"Time zone offset \"{timeZoneOffset.ToString()}\" is not valid"; + LogStatus(JobId, LogJob, log, msg); + throw new System.NotSupportedException(msg); + } + apiServerState.SetOpsOnly("Seeding database"); //Erase all the data except for the license, schema and the manager user DbUtil.PrepareDatabaseForSeeding(log); - Set the time zone of the manager account here + //Set the time zone of the manager account + { + var ct = ServiceProviderProvider.DBContext; + var mgr = ct.UserOptions.FirstAsync(m => m.Id == 1).Result; + mgr.TimeZoneOffset = timeZoneOffset; + ct.SaveChanges(); + } + //Seed special test data for integration testing //log.LogInformation("Seeding known users"); @@ -421,7 +437,7 @@ namespace AyaNova.Util //Children and relations u.UserOptions = new UserOptions(1); 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; var NewObject = Biz.Create(ServiceProviderProvider.DBContext, u); if (NewObject == null)