public ActionResult AddComment(ShortStoryCommentInputModel comment) { if (!this.User.Identity.IsAuthenticated) { this.Response.StatusCode = 401; return(this.Content("Access is denied")); } if (comment == null || !this.ModelState.IsValid) { this.Response.StatusCode = 400; return(this.Content("Bad request")); } var newComment = this.comments.Add(comment.Content, comment.ShortStoryId, this.User.Identity.GetUserId()); if (newComment == null) { this.Response.StatusCode = 400; return(this.Content("Bad request.")); } var viewModel = this.Mapper.Map <ShortStoryCommentViewModel>(newComment); return(this.PartialView("_ShortStoryComment", viewModel)); }
public ActionResult AddComment(int id) { var viewModel = new ShortStoryCommentInputModel() { Content = string.Empty, ShortStoryId = id }; return(this.PartialView("_AddComment", viewModel)); }