/// <summary>
        /// Adds a district to the system, only if it does not exist.
        /// </summary>
        private static void AddInitialDistrict(this IDbAppContext context, District initialDistrict)
        {
            District district = context.GetDistrictByMinistryDistrictId(initialDistrict.MinistryDistrictID);

            if (district != null)
            {
                return;
            }

            district = new District
            {
                MinistryDistrictID = initialDistrict.MinistryDistrictID,
                Name      = initialDistrict.Name,
                StartDate = initialDistrict.StartDate
            };

            if (initialDistrict.Region != null)
            {
                Region region = context.GetRegionByMinistryRegionId(initialDistrict.Region.MinistryRegionID);
                district.Region = region;
            }
            else
            {
                district.Region = null;
            }

            context.Districts.Add(district);
            context.SaveChanges();
        }
Beispiel #2
0
        /// <summary>
        /// Adds a district to the system, only if it does not exist.
        /// </summary>
        private static void AddInitialDistrict(this IDbAppContext context, District initialDistrict)
        {
            District district = context.GetDistrictByMinistryDistrictId(initialDistrict.MinistryDistrictID);

            if (district != null)
            {
                return;
            }

            district = new District
            {
                MinistryDistrictID = initialDistrict.MinistryDistrictID,
                Name                   = initialDistrict.Name,
                StartDate              = initialDistrict.StartDate,
                AppCreateUserid        = SystemId,
                AppCreateTimestamp     = DateTime.UtcNow,
                AppLastUpdateUserid    = SystemId,
                AppLastUpdateTimestamp = DateTime.UtcNow
            };

            if (initialDistrict.Region != null)
            {
                Region region = context.GetRegionByMinistryRegionId(initialDistrict.Region.MinistryRegionID);
                district.Region = region;
            }
            else
            {
                district.Region = null;
            }

            context.Districts.Add(district);
        }
        /// <summary>
        /// Adds a region to the system, only if it does not exist.
        /// </summary>
        private static void AddInitialRegion(this IDbAppContext context, Region initialRegion)
        {
            Region region = context.GetRegionByMinistryRegionId(initialRegion.MinistryRegionID);

            if (region != null)
            {
                return;
            }

            region = new Region();
            region.MinistryRegionID = initialRegion.MinistryRegionID;
            region.Name             = initialRegion.Name;
            region.StartDate        = initialRegion.StartDate;

            context.Regions.Add(region);
            context.SaveChanges();
        }
Beispiel #4
0
        /// <summary>
        /// Adds a region to the system, only if it does not exist.
        /// </summary>
        private static void AddInitialRegion(this IDbAppContext context, Region initialRegion)
        {
            Region region = context.GetRegionByMinistryRegionId(initialRegion.MinistryRegionID);

            if (region != null)
            {
                return;
            }

            region = new Region
            {
                MinistryRegionID       = initialRegion.MinistryRegionID,
                Name                   = initialRegion.Name,
                StartDate              = initialRegion.StartDate,
                AppCreateUserid        = SystemId,
                AppCreateTimestamp     = DateTime.UtcNow,
                AppLastUpdateUserid    = SystemId,
                AppLastUpdateTimestamp = DateTime.UtcNow
            };

            context.Regions.Add(region);
        }