public ActionResult EditForum(EditForumViewModel model) { if (ModelState.IsValid) { var forum = forumService.GetForum(model.Id); if (forum != null) { forum.Name = model.Name; var result = forumService.Update(forum); if (result.Succedeed) { return(RedirectToAction("GetForum", new { id = model.Id })); } else { ModelState.AddModelError("", result.Message); } } } else { ModelState.AddModelError("", "Forum was not found"); } return(View(model)); }
public IActionResult EditForum(EditForumViewModel model) { try { var forum = _mapper.Map <Forum>(model); _forumsRepository.UpdateForum(forum); _unitOfWork.Commit(); return(RedirectToAction(nameof(this.ManageForums))); } catch { return(View()); } }