Example #1
0
 public static void Initialize(this ITownDefViewModel viewModel, IEnumerable<Town> towns)
 {
     QueryNamesService service = new QueryDistinctCityNamesService(towns);
     viewModel.CityList = service.Query().ToList().Select(
             x => new SelectListItem { Value = x, Text = x }).ToList();
     viewModel.DistrictList = new List<SelectListItem>();
     viewModel.TownList = new List<SelectListItem>();
 }
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();
 }