Example #1
0
        public IEnumerable <string> GetTownListByCityAndDistrictName(string cityName, string districtName)
        {
            QueryNamesService service = new QueryDistinctTownNamesService(
                townRepository.GetAll(), cityName, districtName);

            return(service.Query().ToList());
        }
Example #2
0
        public static void Initialize(this ITownDefViewModel viewModel, IEnumerable <Town> towns, ITown town)
        {
            QueryNamesService service = new QueryDistinctCityNamesService(towns);

            viewModel.CityList
                = service.Query().ToList().Select(
                      x => new SelectListItem {
                Value = x, Text = x, Selected = x == town.CityName
            }).ToList();
            service = new QueryDistinctDistrictNamesService(towns, town.CityName);
            viewModel.DistrictList
                = service.Query().ToList().Select(
                      x => new SelectListItem {
                Value = x, Text = x, Selected = x == town.DistrictName
            }).ToList();
            service = new QueryDistinctTownNamesService(towns, town.CityName, town.DistrictName);
            viewModel.TownList
                = service.Query().ToList().Select(
                      x => new SelectListItem {
                Value = x, Text = x, Selected = x == town.TownName
            }).ToList();
        }