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 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 string GetName(string cityName, string districtName) { QueryRegionService service = new ByDistrictQueryRegionService( regionRepository.GetAll(), cityName, districtName); OptimizeRegion region = service.Query(); return((region == null) ? "" : region.Region); }
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 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; } }
public void TestByCityDistrictRegion(int cityId, int districtId, int regionId, bool existed) { OptimizeRegion region = helper.ConstructTestRegion(cityId, districtId, regionId); if (existed) { Assert.IsNotNull(region); } else { Assert.IsNull(region); } }
public static KpiImportResult Import(this IKpiImportController controller, HttpPostedFileBase httpPostedFileBase, string[] sheetNames, IRegionRepository regionRepository, ITopCellRepository <CdmaRegionStat> cdmaStatRepository) { List <CdmaRegionStat> statList = httpPostedFileBase.ImportInfo( x => { List <CdmaRegionStat> stats = new List <CdmaRegionStat>(); using (ExcelImporter excelImporter = new ExcelImporter(x, sheetNames)) { foreach (string sheetName in sheetNames) { using (DataTable statTable = excelImporter[sheetName]) { ImportExcelListService <CdmaRegionStat> service = new ImportExcelListService <CdmaRegionStat>(stats, statTable); service.Import(); } } } return(stats); }, "佛山"); if (statList.Count > 0) { OptimizeRegion firstOrDefault = regionRepository.GetAllList().FirstOrDefault( x => x.Region == statList[0].Region); if (firstOrDefault != null) { controller.SaveTimeKpiStatsService.CurrentCity = firstOrDefault.City; controller.Save3GStatsService.CurrentCity = firstOrDefault.City; } } int regionStatsSaved = cdmaStatRepository.SaveStats(statList); ExcelStatsImportRepository <TopDrop2GCellExcel> drop2GExcelRepository = httpPostedFileBase.ImportInfo( x => new ExcelStatsImportRepository <TopDrop2GCellExcel>(x, "掉话TOP30小区"), "佛山"); int topDrop2GSaved = controller.SaveTimeKpiStatsService.Save(drop2GExcelRepository.StatList); ExcelStatsImportRepository <TopConnection3GCellExcel> connection3GExcelRepository = httpPostedFileBase.ImportInfo( x => new ExcelStatsImportRepository <TopConnection3GCellExcel>(x, "连接TOP30小区"), "佛山"); int topConnection3GSaved = controller.Save3GStatsService.Save(connection3GExcelRepository.StatList); return(new KpiImportResult { RegionStatsSaved = regionStatsSaved, TopDrop2GSaved = topDrop2GSaved, TopConnection3GSaved = topConnection3GSaved }); }
public void TestByCityDistrict(int cityId, int districtId, int regionId) { OptimizeRegion region = helper.ConstructTestRegion(cityId, districtId); if (regionId == -1) { Assert.IsNull(region); } else { Assert.IsNotNull(region); Assert.AreEqual(region.Id, regionId); } }
public bool DeleteOneRegion() { if (InputIsEmpty) { return(false); } OptimizeRegion region = _service.Query(); if (region == null) { return(false); } _repository.Delete(region); return(true); }