public IActionResult Index() { var model = new MenuViewModel() { Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p)) }; return(View(model)); }
public IActionResult AddUpdateCity() { var model = new MenuViewModel() { Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p)) }; return(Json(model)); }
public async Task <IActionResult> AddUpdateCity(MenuViewModel model) { if (ModelState.IsValid) { var city = new City() { Description = model.CityName, CountryId = model.CountryId }; await _repository.Add(city); await _repository.Save(); ModelState.AddModelError("", "City Added Successfully"); } model.Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p)); return(View(model)); }
public IActionResult GetCountries() { var countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p)); return(Json(countries)); }