public ActionResult Edit(FullCommentViewModel comment) { if (comment != null && !String.IsNullOrWhiteSpace(comment.Text)) { _commentService.UpdateCommentEntity(comment.ToBllFullComment()); } return(RedirectToAction("Details", "Article", new { id = comment.ArticleId })); }
public static FullCommentEntity ToBllFullComment(this FullCommentViewModel comment) { return new FullCommentEntity() { Id = comment.Id, DateTime = comment.DateTime, Text = comment.Text, User = comment.User?.ToBllUser(), ArticleId = comment.ArticleId }; }
public ActionResult Create(string Text, int id) { if (!String.IsNullOrWhiteSpace(Text)) { var fullcomment = new FullCommentViewModel(); fullcomment.ArticleId = id; fullcomment.User = _userService.GetUserByNickname(User.Identity.Name).ToMvcUser(); fullcomment.DateTime = DateTime.Now; fullcomment.Text = Text; _commentService.CreateCommentEntity(fullcomment.ToBllFullComment()); if (Request.IsAjaxRequest()) { return(Json(fullcomment)); } } else { ModelState.AddModelError("Text", "Add your message"); } return(RedirectToAction("Details", "Article", new { id })); }
public ActionResult Delete(FullCommentViewModel commentModel) { _commentService.DeleteCommentEntity(commentModel.ToBllFullComment()); return(RedirectToAction("Details", "Article", new { id = commentModel.ArticleId })); }