Exemplo n.º 1
0
        private static void MapEntityConservationArea(GeographicalAreaDto dto, List <AreaCategory> conservationAreaCategories)
        {
            var conservationAreaCategory = conservationAreaCategories.FirstOrDefault(c => c.ShortName == dto.Category);

            if (conservationAreaCategory == null)
            {
                conservationAreaCategory = new AreaCategory
                {
                    ShortName = dto.Category,
                    Name      = AreaCodes.CodeToName(dto.Category)
                };

                conservationAreaCategories.Add(conservationAreaCategory);
            }

            var conservationArea = conservationAreaCategory.ConservationAreas.FirstOrDefault(c => c.Number == int.Parse(dto.Number));

            if (conservationArea == null)
            {
                conservationArea = new ConservationArea
                {
                    Number = int.Parse(dto.Number),
                    Name   = dto.Name
                };

                conservationAreaCategory.ConservationAreas.Add(conservationArea);
            }

            if (dto.NatureAreaId.HasValue)
            {
                conservationArea.NatureAreaIds.Add(dto.NatureAreaId.Value);
            }
        }
Exemplo n.º 2
0
        private static void MapEntityCounty(GeographicalAreaDto dto, List <County> counties)
        {
            var county = counties.FirstOrDefault(na => na.Number == int.Parse(dto.Number));

            if (county == null)
            {
                county = new County
                {
                    Number = int.Parse(dto.Number),
                    Name   = dto.Name
                };

                counties.Add(county);
            }
        }
Exemplo n.º 3
0
        private static void MapEntityMunicipality(GeographicalAreaDto dto, List <County> counties)
        {
            int countyNo = int.Parse(dto.Number) / 100;
            var county   = counties.Single(na => na.Number == countyNo);

            var municipality = county.Municipalities.FirstOrDefault(m => m.Number == int.Parse(dto.Number));

            if (municipality == null)
            {
                municipality = new Municipality
                {
                    Number = int.Parse(dto.Number),
                    Name   = dto.Name
                };

                county.Municipalities.Add(municipality);
            }

            if (dto.NatureAreaId.HasValue)
            {
                municipality.NatureAreaIds.Add(dto.NatureAreaId.Value);
            }
        }