Beispiel #1
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            #region Seeds
            builder.Entity <Country>().HasData(CountrySeed.GetCountries());
            builder.Entity <State>().HasData(StateSeed.GetStates());
            #endregion

            #region Fluent Api
            builder.Entity <ApplicationUser>(entity => entity.Property(m => m.Id).HasMaxLength(85));
            builder.Entity <ApplicationUser>(entity => entity.Property(m => m.NormalizedEmail).HasMaxLength(85));
            builder.Entity <ApplicationUser>(entity => entity.Property(m => m.NormalizedUserName).HasMaxLength(85));

            builder.Entity <ApplicationRole>(entity => entity.Property(m => m.Id).HasMaxLength(85));
            builder.Entity <ApplicationRole>(entity => entity.Property(m => m.NormalizedName).HasMaxLength(85));

            builder.Entity <IdentityUserLogin <int> >(entity => entity.Property(m => m.LoginProvider).HasMaxLength(85));
            builder.Entity <IdentityUserLogin <int> >(entity => entity.Property(m => m.ProviderKey).HasMaxLength(85));
            builder.Entity <IdentityUserLogin <int> >(entity => entity.Property(m => m.UserId).HasMaxLength(85));
            builder.Entity <IdentityUserRole <int> >(entity => entity.Property(m => m.UserId).HasMaxLength(85));

            builder.Entity <IdentityUserRole <int> >(entity => entity.Property(m => m.RoleId).HasMaxLength(85));

            builder.Entity <IdentityUserToken <int> >(entity => entity.Property(m => m.UserId).HasMaxLength(85));
            builder.Entity <IdentityUserToken <int> >(entity => entity.Property(m => m.LoginProvider).HasMaxLength(85));
            builder.Entity <IdentityUserToken <int> >(entity => entity.Property(m => m.Name).HasMaxLength(85));

            builder.Entity <IdentityUserClaim <int> >(entity => entity.Property(m => m.Id).HasMaxLength(85));
            builder.Entity <IdentityUserClaim <int> >(entity => entity.Property(m => m.UserId).HasMaxLength(85));
            builder.Entity <IdentityRoleClaim <int> >(entity => entity.Property(m => m.Id).HasMaxLength(85));
            builder.Entity <IdentityRoleClaim <int> >(entity => entity.Property(m => m.RoleId).HasMaxLength(85));
            #endregion

            base.OnModelCreating(builder);
        }
Beispiel #2
0
        private static void AddCountries(ModelBuilder modelBuilder)
        {
            List <Country> countries = CountrySeed.GetCountries();

            foreach (Country country in countries)
            {
                modelBuilder.Entity <Model.Domain.Lookup.Country>().HasData
                (
                    country
                );
            }
        }
Beispiel #3
0
        public static List <Model.Domain.Calculator.Calculator> GetCalculators()
        {
            List <Model.Domain.Calculator.Calculator> results = new List <Model.Domain.Calculator.Calculator>();


            var calculatorSettings = CalculatorSettingsSeed.GetCalculatorSettings();


            int index = 1;

            foreach (CalculatorSetting calculatorSetting in calculatorSettings.Where(x => x.CountryIso != null))
            {
                results.Add(new Model.Domain.Calculator.Calculator()
                {
                    CalculatorId        = index,
                    CountryIso          = calculatorSetting.CountryIso,
                    CalculatorSettingId = calculatorSetting.CalculatorSettingId
                });
                ++index;
            }



            // for all other countries add a calculator with default settings

            foreach (Enumerations.CountryEnum countryIso in (Enumerations.CountryEnum[])Enum.GetValues(
                         typeof(Enumerations.CountryEnum)))
            {
                String  name                = Enum.GetName(typeof(Enumerations.CountryEnum), countryIso);
                Country country             = CountrySeed.GetCountries().FirstOrDefault(x => x.Iso == name.ToUpper());
                int     calculatorSettingId = country?.RegionId == Enumerations.RegionEnum.Europe ? 2 : 1;

                if (results.All(x => x.CountryIso != name.ToString()))
                {
                    results.Add(new Model.Domain.Calculator.Calculator()
                    {
                        CalculatorId        = index,
                        CountryIso          = name.ToUpper(),
                        CalculatorSettingId = calculatorSettingId
                    });
                }

                ++index;
            }

            return(results);
        }