Exemplo n.º 1
0
        private void SeedDataIdentity(BankAppDataContext context, UserManager <IdentityUser> userManager)
        {
            AddRoleIfNotExists(context, "Admin");
            AddRoleIfNotExists(context, "Cashier");

            AddIfNotExists(userManager, "*****@*****.**", "Cashier");
            AddIfNotExists(userManager, "*****@*****.**", "Admin");
        }
Exemplo n.º 2
0
 private void AddRoleIfNotExists(BankAppDataContext context, string role)
 {
     if (context.Roles.Any(r => r.Name == role))
     {
         return;
     }
     context.Roles.Add(new IdentityRole {
         Name = role, NormalizedName = role
     });
     context.SaveChanges();
 }
Exemplo n.º 3
0
        private void SeedData(BankAppDataContext context)
        {
            if (!context.BatchStatus.Any(r => r.LastId > 0))
            {
                context.BatchStatus.Add(new BatchStatus {
                    LastId = 1
                });
            }

            if (context.MobileAppUsers.Count() == 0)
            {
                context.MobileAppUsers.Add(new MobileAppUsers
                {
                    Username   = "******",
                    Password   = "******",
                    CustomerId = 1
                });

                context.MobileAppUsers.Add(new MobileAppUsers
                {
                    Username   = "******",
                    Password   = "******",
                    CustomerId = 2
                });

                context.MobileAppUsers.Add(new MobileAppUsers
                {
                    Username   = "******",
                    Password   = "******",
                    CustomerId = 3
                });

                context.MobileAppUsers.Add(new MobileAppUsers
                {
                    Username   = "******",
                    Password   = "******",
                    CustomerId = 4
                });

                context.MobileAppUsers.Add(new MobileAppUsers
                {
                    Username   = "******",
                    Password   = "******",
                    CustomerId = 5
                });
            }

            context.SaveChanges();
        }
Exemplo n.º 4
0
 public void InitializeBankApp(BankAppDataContext context, UserManager <IdentityUser> userManager)
 {
     context.Database.Migrate();
     SeedDataIdentity(context, userManager);
     SeedData(context);
 }
Exemplo n.º 5
0
 public void Initialize(BankAppDataContext context)
 {
     //context.Database.EnsureCreated();
     context.Database.Migrate();
     SeedData(context);
 }