public ActionResult Create(CommunicationPhraseViewModel model) { try { // TODO: Add insert logic here if (!ModelState.IsValid) { return(View(model)); } var CommunicationPhrase = _mapper.Map <CommunicationPhrase>(model); var isSuccess = _repo.Create(CommunicationPhrase); if (!isSuccess) { ModelState.AddModelError("", "Something Went Wrong!"); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Something Went Wrong!"); return(View(model)); } }
public ActionResult Delete(int id, CommunicationPhraseViewModel model) { try { // TODO: Add delete logic here var CommunicationPhrase = _repo.FindById(id); if (CommunicationPhrase == null) { return(NotFound()); } var isSuccess = _repo.Delete(CommunicationPhrase); if (!isSuccess) { return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { return(View(model)); } }