Ejemplo n.º 1
0
        public JsonResult GetCities(int countryId)
        {
            ICityServices city = new CityServices();

            CityResponse citiesResponse = city.GetCitiesByCountry(countryId);
            List <City>  citiesList     = new List <City>();

            citiesList = citiesResponse.cities;

            List <SelectListItem> citiesSelectList = new List <SelectListItem>();

            citiesSelectList.Add(new SelectListItem {
                Text = "Seleccione", Value = "0"
            });

            foreach (var cityTemp in citiesList)
            {
                citiesSelectList.Add(new SelectListItem {
                    Text = cityTemp.city, Value = cityTemp.id.ToString()
                });
            }

            return(Json(new SelectList(citiesSelectList, "Value", "Text")));
        }