public async Task <ActionResult> EditMunicipality(MunicipalityViewModel municipality) { if (ModelState.IsValid) { var res = mapper.Map <MunicipalityViewModel, Municipality>(municipality); var isEdited = await _placesService.EditMunicipality(res); if (isEdited) { return(RedirectToAction("Index")); } ModelState.AddModelError("municipality.Code", "El código ya está registrado"); } var municipalities = await _placesService.GetAllMunicipalities(); var mun = mapper.Map <List <Municipality>, List <MunicipalityViewModel> >(municipalities); IndexMunicipalityViewModel indexViewModel = new IndexMunicipalityViewModel(); indexViewModel.ListMunicipalities = mun; indexViewModel.Municipality = municipality; indexViewModel.IsError = true; indexViewModel.IsEditing = true; return(View("Index", indexViewModel)); }