Exemple #1
0
        public static async Task Initialize(AppShopDbContext context, RoleManager <Role> roleManager, UserManager <User> userManager)
        {
            context.Database.EnsureCreated();

            if (!context.Roles.Any())
            {
                // Seed role
                var role = new Role("administrator");
                await roleManager.CreateAsync(role);
            }

            if (!context.Users.Any())
            {
                // Seed user
                var user = new User()
                {
                    FirstName = "Jaromír",
                    LastName  = "Roth",
                    Email     = "*****@*****.**",
                    UserName  = "******"
                };
                var password = "******";

                await userManager.CreateAsync(user, password);

                await userManager.AddToRoleAsync(user, "administrator");
            }
        }
 public UnitOfWork(AppShopDbContext dbContext)
 {
     this._dbContext = dbContext;
 }