public async Task <IViewComponentResult> InvokeAsync(bool isRequired = false, int?cityId = null)
        {
            var counties = await _cityCountyService.GetCountiesAsync();

            IEnumerable <City> cities = new List <City>();
            int?countyId = null;

            if (cityId != null)
            {
                var city = await _cityCountyService.GetCity((int)cityId);

                countyId = city.County !.Id;
                cities   = await _cityCountyService.GetCitiesInCountyAsync((int)countyId);
            }
            ViewModels.CityCountySelect model = new ViewModels.CityCountySelect(counties.ToList())
            {
                IsRequired = isRequired, CityId = cityId, CountyId = countyId, Cities = cities.ToList()
            };

            return(View("CityCountySelect", model));
        }
Пример #2
0
        public async Task <IActionResult> ChooseCounty(int countyId)
        {
            var cities = await _cityCountyService.GetCitiesInCountyAsync(countyId);

            return(PartialView("/Views/Shared/Components/CityCountySelect/_CitySelect.cshtml", cities));
        }