public ActionConfirmation Delete(int id) { Agency agencyToDelete = _agencyRepository.Get(id); if (agencyToDelete != null) { _agencyRepository.Delete(agencyToDelete); try { _agencyRepository.DbContext.CommitChanges(); return(ActionConfirmation.CreateSuccessConfirmation( "The agency was successfully deleted.")); } catch { _agencyRepository.DbContext.RollbackTransaction(); return(ActionConfirmation.CreateFailureConfirmation( "A problem was encountered preventing the agency from being deleted. " + "Another item likely depends on this agency.")); } } else { return(ActionConfirmation.CreateFailureConfirmation( "The agency could not be found for deletion. It may already have been deleted.")); } }
public IActionResult Delete(Agency model) { var result = _agencyRepository.Delete(model.AgencyId); if (result.Success) { return(RedirectToAction("Index")); } else { throw new Exception(result.Messages[0]); } }
public IActionResult Delete(int id) { var response = agencyRepo.Delete(id); if (response.Success) { return(RedirectToAction("Index")); } else { return(BadRequest(response.Message)); } }