예제 #1
0
파일: DatabaseHelper.cs 프로젝트: bcgov/PSP
 /// <summary>
 /// Initializes the database with default data to support other tables.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static PimsContext SeedDatabase(this PimsContext context)
 {
     context.AddRange(EntityHelper.CreateDefaultPropertyClassifications());
     context.AddRange(EntityHelper.CreateDefaultProvinces());
     context.AddRange(EntityHelper.CreateDefaultAdministrativeAreas());
     context.AddRange(EntityHelper.CreateDefaultRoles());
     context.AddRange(EntityHelper.CreateDefaultBuildingPredominateUses());
     context.AddRange(EntityHelper.CreateDefaultBuildingConstructionTypes());
     context.AddRange(EntityHelper.CreateDefaultBuildingOccupantTypes());
     context.AddRange(EntityHelper.CreateDefaultAgencies());
     context.AddRange(EntityHelper.CreateDefaultTierLevels());
     context.AddRange(EntityHelper.CreateDefaultProjectRisks());
     context.SaveChanges();
     return(context);
 }
예제 #2
0
        /// <summary>
        /// Initialize the PimsContext with the specified data in 'entities'.
        /// Initializes the database with default data to support other tables.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="dbName"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static PimsContext InitializeDatabase(this TestHelper helper, string dbName, ClaimsPrincipal user)
        {
            var context = helper.CreatePimsContext(dbName, user, true);

            context.AddRange(EntityHelper.CreateDefaultPropertyClassifications());
            context.AddRange(EntityHelper.CreateDefaultProvinces());
            context.AddRange(EntityHelper.CreateDefaultCities());
            context.AddRange(EntityHelper.CreateDefaultRoles());
            context.AddRange(EntityHelper.CreateDefaultBuildingPredominateUses());
            context.AddRange(EntityHelper.CreateDefaultBuildingConstructionTypes());
            context.AddRange(EntityHelper.CreateDefaultBuildingOccupantTypes());
            context.AddRange(EntityHelper.CreateDefaultAgencies());
            context.AddRange(EntityHelper.CreateDefaultTierLevels());
            context.AddRange(EntityHelper.CreateDefaultProjectRisks());
            context.SaveChanges();
            return(context);
        }
예제 #3
0
        /// <summary>
        /// Initializes the database with default data to support other tables.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static PimsContext SeedDatabase(this PimsContext context)
        {
            var countries                   = EntityHelper.CreateDefaultCountries();
            var regions                     = EntityHelper.CreateDefaultRegions();
            var organizationTypes           = EntityHelper.CreateDefaultOrganizationTypes();
            var organizationIdentifierTypes = EntityHelper.CreateDefaultOrganizationIdentifierTypes();

            context.AddRange(countries);
            context.AddRange(regions);
            context.AddRange(organizationTypes);
            context.AddRange(organizationIdentifierTypes);
            context.AddRange(EntityHelper.CreateDefaultRoles());
            context.AddRange(EntityHelper.CreateDefaultPropertyTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyClassificationTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyTenureTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyAreaUnitTypes());
            context.AddRange(EntityHelper.CreateDefaultDataSourceTypes());
            context.AddRange(EntityHelper.CreateDefaultContactMethodTypes());
            context.AddRange(EntityHelper.CreateDefaultProvinces(countries.First()));
            context.AddRange(EntityHelper.CreateDefaultDistricts(regions.First()));
            context.AddRange(EntityHelper.CreateDefaultOrganizations(organizationTypes.First(), organizationIdentifierTypes.First()));
            context.SaveChanges();
            return(context);
        }