public ActionResult Create(CreativityPhraseViewModel model) { try { // TODO: Add insert logic here if (!ModelState.IsValid) { return(View(model)); } var CreativityPhrase = _mapper.Map <CreativityPhrase>(model); var isSuccess = _repo.Create(CreativityPhrase); 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, CreativityPhraseViewModel model) { try { // TODO: Add delete logic here var CreativityPhrase = _repo.FindById(id); if (CreativityPhrase == null) { return(NotFound()); } var isSuccess = _repo.Delete(CreativityPhrase); if (!isSuccess) { return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { return(View(model)); } }