From fbd6b249abf4610e99240e02063899bd87ff1f56 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 26 Sep 2018 19:27:24 +0000 Subject: [PATCH] --- server/AyaNova/util/Seeder.cs | 85 +---------------------------------- 1 file changed, 2 insertions(+), 83 deletions(-) diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 405e0784..2ea0fe8f 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -206,9 +206,6 @@ namespace AyaNova.Util - - - /// /// Generate seed user with active=true /// (override to save typing) @@ -223,67 +220,8 @@ namespace AyaNova.Util GenSeedUser(count, roles, userType, true, login, password); } - // ////////////////////////////////////////////////////// - // //Seed user - default login / pw is first name - // // - // public static void GenSeedUser(int count, AuthorizationRoles roles, UserType userType, bool active = true, string login = null, string password = null) - // { - // AyContext ct = ServiceProviderProvider.DBContext; - // for (int x = 0; x < count; x++) - // { - // User u = new User(); - // u.Active = active; - // u.OwnerId = 1; - // var p = new Bogus.Person(); - // u.Name = p.FullName; - // u.Salt = Hasher.GenerateSalt(); - // if (login != null) - // { - // u.Login = login; - // u.Name += " - " + login; - // } - // else - // u.Login = p.FirstName; - // if (password != null) - // u.Password = Hasher.hash(u.Salt, password); - // else - // u.Password = Hasher.hash(u.Salt, u.Login); - // u.Roles = roles; - // u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID; - // u.UserType = userType; - // //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 - - // //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"); - - // ct.User.Add(u); - // } - // //save to get id values - // ct.SaveChanges(); - - // //Now that we have the ID values bulk add the event log entries - // //To save a db call iterate the local collection in the context, but... - // //can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list - // List ItemsAdded = new List(); - // foreach (User o in ct.User.Local) - // { - // ItemsAdded.Add(o.Id); - // } - - // //Now we have all the id's can actually add them to the context - // foreach (long l in ItemsAdded) - // { - // EventLogProcessor.AddEntry(new Event(1, l, AyaType.User, AyaEvent.Created), ct); - // } - - // //Now save the Event Log entries - // ct.SaveChanges(); - // } - - - public static void GenSeedUser(int count, AuthorizationRoles roles, UserType userType, bool active = true, string login = null, string password = null) + public async static void GenSeedUser(int count, AuthorizationRoles roles, UserType userType, bool active = true, string login = null, string password = null) { UserBiz Biz = UserBiz.GetBizInternal(ServiceProviderProvider.DBContext); // Biz.CreateAsync() @@ -316,28 +254,9 @@ namespace AyaNova.Util 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"); - Biz.CreateAsync(u).Wait(); + await Biz.CreateAsync(u); } - //save to get id values - // ct.SaveChanges(); - //Now that we have the ID values bulk add the event log entries - //To save a db call iterate the local collection in the context, but... - //can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list - // List ItemsAdded = new List(); - // foreach (User o in ct.User.Local) - // { - // ItemsAdded.Add(o.Id); - // } - - // //Now we have all the id's can actually add them to the context - // foreach (long l in ItemsAdded) - // { - // EventLogProcessor.AddEntry(new Event(1, l, AyaType.User, AyaEvent.Created), ct); - // } - - // //Now save the Event Log entries - // ct.SaveChanges(); } //////////////////////////////////////////////////////