Exemplo n.º 1
0
        protected override void Seed(DurandalAuthDbContext context)
        {
            var userManager = new UserManager <UserProfile>(new UserStore <UserProfile>(context));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));

            if (!roleManager.RoleExists("Administrator"))
            {
                roleManager.Create(new IdentityRole("Administrator"));
            }

            if (!roleManager.RoleExists("User"))
            {
                roleManager.Create(new IdentityRole("User"));
            }

            if (userManager.FindByName("admin") == null)
            {
                var user = new UserProfile {
                    UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
                };
                var result = userManager.Create(user, "admin1234");
                if (result.Succeeded)
                {
                    userManager.AddToRole(user.Id, "Administrator");
                }
            }

            var uow = new DurandalAuthDbContext();

            var hasChanges = false;

            //SetCategoryData(uow);
            ProvinceData.SetProvinceData(uow, ref hasChanges);
            GenderData.SetGenderData(uow, ref hasChanges);
            // EthnicityData.SetEthnicityData(uow, ref hasChanges);
            //LanguageData.SetLanguageData(uow, ref hasChanges);
            EmploymentData.SetEmploymentStatus(uow, ref hasChanges);

            /* PsiraGradeData.SetPsiraGradeData(uow, ref hasChanges);
             * SecurityTrainingData.SetSecurityTrainingData(uow, ref hasChanges);*/
            DecisionData.SetYesNoLookupData(uow, ref hasChanges);
            //PsiraCategoryData.SetPsiraCategoryLookup(uow, ref hasChanges);
            //CityData.SetCityNameData(uow, ref hasChanges);
            AddressData.SetAddressData(uow, ref hasChanges);
            //MaritalStatusData.SetMaritalStatusData(uow, ref hasChanges);
            EntityTypeData.SetEntityData(uow, ref hasChanges);
            TitleData.SetTitleData(uow, ref hasChanges);

            if (hasChanges)
            {
                uow.SaveChanges();
            }
        }