Exemple #1
0
        protected override void Seed(KitKareDbContext context)
        {
            this.userManager = new UserManager <User>(new UserStore <User>(context));

            this.SeedRoles(context);
            this.SeedUsers(context);
        }
Exemple #2
0
        private void SeedUsers(KitKareDbContext context)
        {
            if (context.Users.Any())
            {
                return;
            }

            this.SeedAdmin(context);
            this.SeedRegularUsers(context);
        }
Exemple #3
0
        private void SeedRoles(KitKareDbContext context)
        {
            if (context.Roles.Any())
            {
                return;
            }

            context.Roles.AddOrUpdate(x => x.Name, new IdentityRole("Admin"));
            context.SaveChanges();
        }
Exemple #4
0
        private void SeedAdmin(KitKareDbContext context)
        {
            var admin = new User
            {
                Email    = "*****@*****.**",
                UserName = "******"
            };

            this.userManager.Create(admin, "admin11");
            this.userManager.AddToRole(admin.Id, "Admin");

            context.SaveChanges();
        }
Exemple #5
0
        private void SeedRegularUsers(KitKareDbContext context)
        {
            for (int i = 0; i < 10; i++)
            {
                var user = new User
                {
                    Email    = "*****@*****.**",
                    UserName = "******" + i
                };

                this.userManager.Create(user, "user11");
                seededUsersIds.Add(user.Id);
            }

            context.SaveChanges();
        }