public async Task <IActionResult> Delete(TownDeleteViewModel townDelete) { if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName)) { return(this.Redirect("/Identity/Account/AccessDenied")); } if (!this.ModelState.IsValid) { var error = new TownError { ErrorMessage = GlobalConstants.TownModelValidationMessаge }; return(this.RedirectToAction("Error", "Town", error)); } var dtoModel = TownDeleteHandMapper.Map(townDelete); var isDeleted = await this.townService.DeleteTownAsync(dtoModel); if (!isDeleted) { var error = new TownError { ErrorMessage = GlobalConstants.TownDeleteErrorMessage }; return(this.RedirectToAction("Error", "Town", error)); } return(this.Redirect("/Town/Index")); }
public static TownDeleteDtoModel Map(TownDeleteViewModel viewModel) { var dtoModel = new TownDeleteDtoModel { TownId = viewModel.TownId }; return(dtoModel); }