public bool SaveOneRegion(bool forceChangeExisted = false) { if (InputIsEmpty) { return(false); } QueryRegionService districtService = new ByDistrictQueryRegionService(_repository.GetAll(), _cityName, _districtName); OptimizeRegion existedRegion = districtService.Query(); if (existedRegion == null) { if (_service.Query() == null) { _repository.Insert(new OptimizeRegion { City = _cityName, District = _districtName, Region = _regionName }); return(true); } } else if (_regionName != existedRegion.Region && forceChangeExisted) { existedRegion.Region = _regionName; _repository.Update(existedRegion); return(true); } return(false); }
public bool SaveOneRegion(bool forceChangeExisted = false) { if (InputIsEmpty) { return false; } QueryRegionService districtService = new ByDistrictQueryRegionService(_repository.GetAll(), _cityName, _districtName); OptimizeRegion existedRegion = districtService.Query(); if (existedRegion == null) { if (_service.Query() == null) { _repository.Insert(new OptimizeRegion { City = _cityName, District = _districtName, Region = _regionName }); return true; } } else if (_regionName != existedRegion.Region && forceChangeExisted) { existedRegion.Region = _regionName; _repository.Update(existedRegion); return true; } return false; }
public TownENodebStat(Town town, IEnumerable<ENodeb> eNodebs, IRegionRepository regionRepository) { town.CloneProperties(this); TownId = town.Id; QueryRegionService service = new ByDistrictQueryRegionService( regionRepository.GetAll(), town.CityName, town.DistrictName); OptimizeRegion region = service.Query(); RegionName = (region == null) ? "" : region.Region; TotalENodebs = eNodebs.Count(x => x.TownId == TownId); }
public string GetName(string cityName, string districtName) { QueryRegionService service = new ByDistrictQueryRegionService( regionRepository.GetAll(), cityName, districtName); OptimizeRegion region = service.Query(); return (region == null) ? "" : region.Region; }
public void AssertInitialRegion(string cityName, string districtName, string regionName) { controller.TempData["RegionViewModel"] = new RegionViewModel("") { CityName = cityName, DistrictName = districtName, RegionName = regionName }; regionRepository.Setup(x => x.GetAll()).Returns(regions.AsQueryable()); regionRepository.Setup(x => x.GetAllList()).Returns(regionRepository.Object.GetAll().ToList()); regionRepository.Setup(x => x.Count()).Returns(regionRepository.Object.GetAll().Count()); ViewResult result = controller.Region(); RegionViewModel viewModel = result.Model as RegionViewModel; QueryRegionService service = new ByDistrictQueryRegionService(regions, cityName, districtName); OptimizeRegion region = service.Query(); if (region != null) { if (viewModel != null) Assert.AreEqual(viewModel.RegionName, region.Region); } }
public static void Initialize(this IRegionViewModel viewModel, IEnumerable<OptimizeRegion> regions, ITown town) { QueryRegionService service = new ByDistrictQueryRegionService(regions, town.CityName, town.DistrictName); OptimizeRegion region = service.Query(); if (region != null) { viewModel.RegionName = region.Region; } }