public async Task <ActionResult> EditRegion(SaveEditRegionViewModel region) { bool isEdited = false; if (ModelState.IsValid) { var res = mapper.Map <SaveEditRegionViewModel, Region>(region); isEdited = await _placesService.EditRegion(res); if (!isEdited) { ModelState.AddModelError("region.Code", "El código ya está registrado"); } } var regionMunicipalities = await _placesService.GetMunicipalitiesByRegion(region.Id); var listMunicipalities = mapper.Map <List <Municipality>, List <MunicipalityViewModel> >(regionMunicipalities); RegionViewModel viewRegion = new RegionViewModel() { Code = region.Code, Id = region.Id, Name = region.Name }; EditRegionViewModel viewModel = new EditRegionViewModel() { Region = viewRegion, Municipalities = listMunicipalities, OriginalName = (isEdited) ? region.Name : region.OriginalName }; return(View(viewModel)); }