public List <BusinessRuleRegionDTO> GetAllRegions() { var res = new List <BusinessRuleRegionDTO>(); var entities = _operationDB.Regions.Where(x => x.IsDeleted == false && x.RegionTypeId == (int)RegionType.NORMAL).ToList(); if (entities != null && entities.Any()) { foreach (var item in entities) { var model = new BusinessRuleRegionDTO() { RegionId = item.RegionId, RegionName = item.RegionName, RegionTypes = (int)RegionType.NORMAL }; if (item.RegionPoints != null && item.RegionPoints != "") { var points = new List <MapPointDTO>(); var allPoints = item.RegionPoints.Split(';'); if (allPoints != null && allPoints.Any()) { foreach (var point in allPoints) { var latLonPair = point.Split('&'); if (latLonPair != null && latLonPair.Count() == 2) { var mapPoint = new MapPointDTO { Latitude = double.Parse(latLonPair[0]), Longitude = double.Parse(latLonPair[1]) }; points.Add(mapPoint); } } } model.RegionPoints = points; } res.Add(model); } } return(res); }
public BusinessRuleRegionDTO GetRegionById(int regionId) { var entity = _operationDB.Regions.FirstOrDefault(x => x.IsDeleted == false && x.RegionId == regionId); if (entity != null) { var model = new BusinessRuleRegionDTO() { RegionId = entity.RegionId, RegionName = entity.RegionName, RegionTypes = (int)RegionType.NORMAL }; if (entity.RegionPoints != null && entity.RegionPoints != "") { var points = new List <MapPointDTO>(); var allPoints = entity.RegionPoints.Split(';'); if (allPoints != null && allPoints.Any()) { foreach (var point in allPoints) { var latLonPair = point.Split('&'); if (latLonPair != null && latLonPair.Count() == 2) { var mapPoint = new MapPointDTO { Latitude = double.Parse(latLonPair[0]), Longitude = double.Parse(latLonPair[1]) }; points.Add(mapPoint); } } } model.RegionPoints = points; } return(model); } return(new BusinessRuleRegionDTO()); }