예제 #1
0
        public IEnumerable <string> GetDistrictListByCityName(string cityName)
        {
            QueryNamesService service = new QueryDistinctDistrictNamesService(
                townRepository.GetAll(), cityName);

            return(service.Query().ToList());
        }
예제 #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();
        }