Пример #1
0
        public static void SeedData(BankAppDataContext dbContext, UserManager <IdentityUser> userManager)
        {
            dbContext.Database.Migrate();

            SeedRoles(dbContext);
            SeedUsers(userManager);
            SeedPersoner(dbContext);
        }
Пример #2
0
        private static void SeedPersoner(BankAppDataContext dbContext)
        {
            var person = dbContext.Users.FirstOrDefault(r => r.FirstName == "Nichole Tsykhotsky");

            if (person == null)
            {
                dbContext.Users.Add(new User
                {
                    FirstName    = "Nichole",
                    LoginName    = "nichole,[email protected]",
                    LastName     = "Tsykhotsky",
                    PasswordHash = new byte[24]
                });
            }

            dbContext.SaveChanges();
        }
Пример #3
0
        private static void SeedRoles(BankAppDataContext dbContext)
        {
            var role = dbContext.Roles.FirstOrDefault(r => r.Name == "Admin");

            if (role == null)
            {
                dbContext.Roles.Add(new IdentityRole {
                    Name = "Admin", NormalizedName = "Admin"
                });
            }
            role = dbContext.Roles.FirstOrDefault(r => r.Name == "Cashier");
            if (role == null)
            {
                dbContext.Roles.Add(new IdentityRole {
                    Name = "Cashier", NormalizedName = "Cashier"
                });
            }
            dbContext.SaveChanges();
        }