public ActionResult Edit(int id, OrgWithCommentsMvcViewModel model) { if (ModelState.IsValid == false) { return(View(model.Comment)); } if (model.Comment.Id == 0) { throw new HttpException((int)HttpStatusCode.InternalServerError, "Не указан идентификатор комментария"); } var comment = model.Comment; var result = _commentService.Save(Mapper.Map <CommentDto>(comment)); if (!result.Succeeded) { ModelState.AddModelError("", $"Ошибки при обновлении комментария:</br>" + $"{string.Join("</br>", result.Errors)}"); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Create(OrgWithCommentsMvcViewModel model) { if (ModelState.IsValid == false) { return(View(model)); } var comment = model.Comment; var result = _commentService.Save(Mapper.Map <CommentDto>(comment)); if (!result.Succeeded) { ModelState.AddModelError("", $"Ошибки при добавлении комментария:</br>" + $"{string.Join("</br>", result.Errors)}"); return(View(model)); } return(RedirectToAction("Organizations", "Home")); }