示例#1
0
 public static void InitializeTownList(this IENodebQueryViewModel viewModel,
     ITownRepository townRepository, ITown town = null)
 {
     if (town != null)
     {
         viewModel.Initialize(townRepository.GetAll(), town);
     }
     else
     {
         viewModel.Initialize(townRepository.GetAll());
     }
 }
示例#2
0
 public static IEnumerable<ENodeb> QueryWithNames(this IRepository<ENodeb> repository,
     ITownRepository townRepository, string city, string district, string town, string eNodebName,
     string address)
 {
     IEnumerable<Town> _townList = townRepository.GetAll().QueryTowns(city, district, town).ToList();
     return (!_townList.Any())
         ? null
         : repository.Query(eNodebName, address, _townList);
 }
 public DeleteOneENodebService(IENodebRepository repository, ITownRepository townRepository,
     string cityName, string districtName, string townName, string eNodebName)
     : this(repository)
 {
     if (townRepository == null)
     {
         _eNodeb = null;
     }
     else
     {
         int townId = townRepository.GetAll().QueryId(cityName, districtName, townName);
         _eNodeb = repository.GetAll().FirstOrDefault(x => x.TownId == townId && x.Name == eNodebName);
     }
 }
 public static IEnumerable<ENodeb> QueryWithNames(this IRepository<ENodeb> repository,
     ITownRepository townRepository, string city, string district, string town, string eNodebName,
     string address)
 {
     IEnumerable<Town> _townList = townRepository.GetAll().QueryTowns(city, district, town).ToList();
     return (!_townList.Any())
         ? null
         : repository.GetAllList().Where(x =>
             _townList.FirstOrDefault(t => t.Id == x.TownId) != null
             && (string.IsNullOrEmpty(eNodebName) || x.Name.IndexOf(eNodebName.Trim(),
                 StringComparison.Ordinal) >= 0)
             && (string.IsNullOrEmpty(address) || x.Address.IndexOf(address.Trim(),
                 StringComparison.Ordinal) >= 0));
 }
示例#5
0
        public static IEnumerable <ENodeb> QueryWithNames(this IRepository <ENodeb> repository,
                                                          ITownRepository townRepository, string city, string district, string town, string eNodebName,
                                                          string address)
        {
            IEnumerable <Town> _townList = townRepository.GetAll().QueryTowns(city, district, town).ToList();

            return((!_townList.Any())
                ? null
                : repository.GetAllList().Where(x =>
                                                _townList.FirstOrDefault(t => t.Id == x.TownId) != null &&
                                                (string.IsNullOrEmpty(eNodebName) || x.Name.IndexOf(eNodebName.Trim(),
                                                                                                    StringComparison.Ordinal) >= 0) &&
                                                (string.IsNullOrEmpty(address) || x.Address.IndexOf(address.Trim(),
                                                                                                    StringComparison.Ordinal) >= 0)));
        }
示例#6
0
        public bool SaveOneBts(BtsExcel btsInfo, bool updateBts)
        {
            _townId = _townRepository.GetAll().QueryId(btsInfo.DistrictName, btsInfo.TownName);
            string  name = btsInfo.Name;
            CdmaBts bts  = _repository.QueryBts(_townId, name);
            CdmaBts existedENodebWithSameId = _repository.GetAll().FirstOrDefault(x => x.BtsId == btsInfo.BtsId);
            bool    addENodeb = false;

            if (bts == null)
            {
                bts = existedENodebWithSameId;
                if (bts == null)
                {
                    bts       = new CdmaBts();
                    addENodeb = true;
                }
            }
            else if (bts != existedENodebWithSameId)
            {
                return(false);
            }

            if (addENodeb)
            {
                bts.TownId = _townId;
                bts.Import(btsInfo, true);
                _repository.Insert(bts);
            }
            else if (updateBts)
            {
                const double tolerance = 1E-6;
                if (Math.Abs(bts.Longtitute) < tolerance && Math.Abs(bts.Lattitute) < tolerance)
                {
                    bts.TownId = _townId;
                    bts.Import(btsInfo, false);
                    _repository.Update(bts);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
        public ActionResult CollgeEdit(CollegeEditViewModel viewModel)
        {
            Town town = _townRepository.GetAll().FirstOrDefault(x =>
                                                                x.CityName == viewModel.CollegeDto.CityName &&
                                                                x.DistrictName == viewModel.CollegeDto.DistrictName &&
                                                                x.TownName == viewModel.CollegeDto.TownName);
            int townId = town == null ? -1 : town.Id;

            CollegeInfo info = viewModel.CollegeDto.Id == -1
                ? new CollegeInfo()
                : _repository.Get(viewModel.CollegeDto.Id);

            if (info == null)
            {
                TempData["error"] = "该校园不存在。无法修改!";
                return(RedirectToAction("List"));
            }
            int    oldTownId = info.TownId;
            string oldName   = info.Name;

            viewModel.CollegeDto.CloneProperties(info);
            info.TownId = townId;
            if (viewModel.CollegeDto.Id == -1)
            {
                _repository.Insert(info);
                TempData["success"] = "新增校园" + info.Name + "信息成功!";
            }
            else
            {
                info.TownId         = oldTownId;
                info.Name           = oldName;
                TempData["success"] = "修改校园" + info.Name + "信息成功!";
                _repository.Update(info);
            }
            return(RedirectToAction("List"));
        }
 public RegionAndDeleteTownTestHelper(RegionController controller, ITownRepository townRepository)
 {
     this.controller = controller;
     this.townRepository = townRepository;
     service = new QueryDistinctCityNamesService(townRepository.GetAll());
 }
示例#9
0
 public RegionAndDeleteTownTestHelper(RegionController controller, ITownRepository townRepository)
 {
     this.controller     = controller;
     this.townRepository = townRepository;
     service             = new QueryDistinctCityNamesService(townRepository.GetAll());
 }
 public int ConstructTestId(int cityId, int districtId)
 {
     service = new QueryDistinctTownNamesService(repository.GetAll(), "C-" + cityId, "D-" + districtId);
     return(service.QueryCount());
 }
示例#11
0
 public IEnumerable <Town> GetAll(String server, int world)
 {
     return(_context.GetAll(server, world));
 }
示例#12
0
 public List <string> GetCities()
 {
     return(_repository.GetAll().Select(x => x.CityName).Distinct().ToList());
 }
示例#13
0
 /// <summary>
 /// Method whose purpose is to return all
 /// town records from the database.
 /// </summary>
 /// <returns>
 /// Returns all town objects as a IList
 /// of TownModel objects.
 /// </returns>
 public IList <TownModel> GetAll()
 {
     return(_townRepository.GetAll());
 }
 public async Task <IActionResult> Index()
 {
     return(View(await _townRepository.GetAll()));
 }
示例#15
0
 public List <Town> GetAll()
 {
     return(_townRepository.GetAll());
 }
示例#16
0
 public void InitializeTownList(ITownRepository townRepository, ITown town)
 {
     if (town != null)
     {
         CityName = town.CityName;
         DistrictName = town.DistrictName;
         TownName = town.TownName;
         this.Initialize(townRepository.GetAll(), town);
     }
     else
     {
         this.Initialize(townRepository.GetAll());
     }
 }