// // GET: /comment/add public ActionResult Add(CommentViewModel commentViewModel) { var commentStatus = false; if (ModelState.IsValid) { if ((commentViewModel.DisplayName == null && commentViewModel.IsHuman == "on") || Request.IsAuthenticated) { commentViewModel.Comment.PostID = commentViewModel.Post.PostID; if (Request.IsAuthenticated) commentViewModel.Comment.UserID = GetUserId(); var commentProcessor = GetCommentProcessor(commentViewModel.Comment); commentProcessor.ProcessComment(); commentStatus = true; } } else { TempData["CommentErrors"] = GetModelErrors(); } return RedirectByPostType(commentViewModel, commentStatus); }
private ActionResult RedirectByPostType(CommentViewModel commentViewModel, bool commentingStatus) { var commentStatus = commentingStatus ? "comment-posted" : "comment-errored"; if (commentViewModel.Post.EntryType == 1) { return RedirectToRoute("IndividualPost", new { year = commentViewModel.Post.PostAddedDate.Year, month = commentViewModel.Post.PostAddedDate.Month.ToString("00"), url = commentViewModel.Post.PostUrl, status = commentStatus }); } return RedirectToRoute("Pages", new { pageUrl = commentViewModel.Post.PostUrl, status = commentStatus }); }