public void PerformInitialSetup(AppIdentityDbContext context) { AppUserManager userMgr = new AppUserManager(new UserStore <AppUser>(context)); AppRoleManager roleMgr = new AppRoleManager(new RoleStore <AppRole>(context)); string roleName = "Administrators"; string userName = "******"; string password = "******"; string email = "*****@*****.**"; if (!roleMgr.RoleExists(roleName)) { roleMgr.Create(new AppRole(roleName)); } AppUser user = userMgr.FindByName(userName); if (user == null) { userMgr.Create(new AppUser { UserName = userName, Email = email }, password); user = userMgr.FindByName(userName); } if (!userMgr.IsInRole(user.Id, roleName)) { userMgr.AddToRole(user.Id, roleName); } }
public void PerformInitialSetup(AppIdentityDbContext context) { // настройки конфигурации контекста будут указываться здесь AppUserManager userMgr = new AppUserManager(new UserStore <AppUser>(context)); AppRoleManager roleMgr = new AppRoleManager(new RoleStore <AppRole>(context)); string roleName = "Адміністратори"; string userName = "******"; string password = "******"; string email = "*****@*****.**"; if (!roleMgr.RoleExists(roleName)) { roleMgr.Create(new AppRole(roleName)); } AppUser user = userMgr.FindByName(userName); if (user == null) { userMgr.Create(new AppUser { UserName = userName, Email = email }, password); user = userMgr.FindByName(userName); } if (!userMgr.IsInRole(user.Id, roleName)) { userMgr.AddToRole(user.Id, roleName); } }
public void PerformInitialSetup(AppIdentityDbContext context) { // настройки конфигурации контекста будут указываться здесь AppUserManager userMgr = new AppUserManager(new UserStore <AppUser>(context)); AppRoleManager roleMgr = new AppRoleManager(new RoleStore <AppRole>(context)); string roleName = "Admin"; string userName = "******"; string password = "******"; string email = "*****@*****.**"; if (!roleMgr.RoleExists(roleName)) { roleMgr.Create(new AppRole(roleName)); } AppUser user = userMgr.FindByName(userName); if (user == null) { userMgr.Create(new AppUser { UserName = userName, Email = email, AvatarPath = AppDomain.CurrentDomain.BaseDirectory + "Content\\UserProfiles\\defaultAvatar.jpg", AvatarImageMimeType = "image/jpeg" }, password); user = userMgr.FindByName(userName); } if (!userMgr.IsInRole(user.Id, roleName)) { userMgr.AddToRole(user.Id, roleName); } }
public void PerformInitialSetup(AppIdentityDbContext context) { //setup users and roles AppUserManager userMgr = new AppUserManager(new UserStore <AppUser>(context)); AppRoleManager roleMgr = new AppRoleManager(new RoleStore <AppRole>(context)); string roleName = "Administrators"; string userName = "******"; string password = "******"; string email = "*****@*****.**"; if (!roleMgr.RoleExists(roleName)) { roleMgr.Create(new AppRole(roleName)); } AppUser user = userMgr.FindByName(userName); if (user == null) { userMgr.Create(new AppUser { UserName = userName, Email = email }, password); user = userMgr.FindByName(userName); } if (!userMgr.IsInRole(user.Id, roleName)) { userMgr.AddToRole(user.Id, roleName); } // initial configuration will go here Content mycontent = new Content() { Body = "Hello", Byline = "By line hehe", CreationDate = DateTime.Now, Seo = "Helllo seo", TagLine = "Tag line", Teaser = "Hi Teaser", Title = "Det me title", UpdatedDate = DateTime.Now, ViewCount = 0, UserId = userMgr.FindByName("Admin").Id }; Setting seedsetting1 = new Setting(); seedsetting1.Name = "AdminEmail"; seedsetting1.Type = "GeneralSettings"; seedsetting1.Value = "*****@*****.**"; Setting seedsetting2 = new Setting(); seedsetting2.Name = "SiteName"; seedsetting2.Type = "GeneralSettings"; seedsetting2.Value = "Alumc"; Setting seedsetting3 = new Setting(); seedsetting3.Name = "HomeMetaDescription"; seedsetting3.Type = "SeoSettings"; seedsetting3.Value = "Alumc Seosettings"; Setting seedsetting4 = new Setting(); seedsetting4.Name = "HomeMetaTitle"; seedsetting4.Type = "SeoSettings"; seedsetting4.Value = "Alumc Title settings"; context.Settings.Add(seedsetting1); context.Settings.Add(seedsetting2); context.Settings.Add(seedsetting3); context.Settings.Add(seedsetting4); context.Contents.Add(mycontent); context.SaveChanges(); }