public IndexModel( DevelopContext context, IAuthorizationService authorizationService, UserManager <AppUser> userManager) : base(context, authorizationService, userManager) { }
public DI_BasePageModel( DevelopContext context, IAuthorizationService authorizationService, UserManager <AppUser> userManager) : base() { Context = context; UserManager = userManager; AuthorizationService = authorizationService; }
public static async Task Initialize(IServiceProvider serviceProvider, string testUserPw) { using (var context = new DevelopContext( serviceProvider.GetRequiredService <DbContextOptions <DevelopContext> >())) { // For sample purposes seed both with the same password. // Password is set with the following: // dotnet user-secrets set SeedUserPW <pw> // The admin user can do anything var adminID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**"); await EnsureRole(serviceProvider, adminID, Constants.ContactAdministratorsRole); // allowed user can create and edit contacts that they create var managerID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**"); await EnsureRole(serviceProvider, managerID, Constants.ContactManagersRole); SeedDB(context, adminID); } }
public static void SeedDB(DevelopContext context, string adminID) { if (context.Contacts.Any()) { return; // DB has been seeded } context.Contacts.AddRange( new Contact { Name = "叶文洁", Address = "文一路", City = "杭州市", Province = "浙江省", Zip = "310000", Email = "*****@*****.**", Status = ContactStatus.Approved, OwnerID = adminID }, new Contact { Name = "汪淼", Address = "文二路", City = "杭州市", Province = "浙江省", Zip = "310000", Email = "*****@*****.**", Status = ContactStatus.Submitted, OwnerID = adminID }, new Contact { Name = "史强", Address = "文三路", City = "杭州市", Province = "浙江省", Zip = "310000", Email = "*****@*****.**", Status = ContactStatus.Rejected, OwnerID = adminID }, new Contact { Name = "罗辑", Address = "天目山路", City = "杭州市", Province = "浙江省", Zip = "310000", Email = "*****@*****.**", Status = ContactStatus.Submitted, OwnerID = adminID }, new Contact { Name = "章北海", Address = "万塘路", City = "杭州市", Province = "浙江省", Zip = "310000", Email = "*****@*****.**", OwnerID = adminID } ); context.SaveChanges(); }