This commit is contained in:
@@ -206,9 +206,6 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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<long> ItemsAdded = new List<long>();
|
||||
// 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<long> ItemsAdded = new List<long>();
|
||||
// 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();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user