private bool changeState(PostCommentAddress commentAddress, EntityState state, string pluginEventName) { bool commentStateChanged = false; PostComment comment = getComment(commentAddress); using (TransactionScope transaction = new TransactionScope()) { if (comment != null && comment.State != state) { commentRepository.ChangeState(comment.ID, state); commentStateChanged = commentRepository.GetComment(comment.ID).State == state; } if (commentStateChanged) { cache.InvalidateItem(comment); } transaction.Complete(); } if (commentStateChanged) { pluginEngine.ExecuteAll(pluginEventName, new { context, parent = new PostSmallReadOnly(comment.Post), comment = new CommentReadOnly(comment, absolutePathHelper.GetAbsolutePath(comment)) }); } return(commentStateChanged); }
public ActionResult CommentOnCommentPartial(PostCommentAddress commentAddress /*Guid? id*/) { //TODO: (erikpo) Need to fix PostComment comment = null; //commentService.GetComment(id ?? Guid.Empty); if (comment == null) { return(Content("")); } return(PartialView("CommentOnComment", new OxiteViewModelPartial <PostComment>(new OxiteViewModel(), comment))); }
public ModelResult <PostComment> EditComment(PostCommentAddress commentAddress, CommentInput commentInput) { commentInput = pluginEngine.Process("ProcessInputOfComment", new CommentIn(commentInput)).ToCommentInput(); commentInput = pluginEngine.Process("ProcessInputOfCommentOnEdit", new CommentIn(commentInput)).ToCommentInput(); if (pluginEngine.AnyTrue("IsCommentSpam", commentInput)) { return(new ModelResult <PostComment>(new ValidationStateDictionary(typeof(CommentInput), new ValidationState(new[] { new ValidationError("Comment.IsSpam", commentInput, "The supplied comment was considered to be spam and was not added") })))); } ValidationStateDictionary validationState = ValidateCommentInput(commentInput); if (!validationState.IsValid) { return(new ModelResult <PostComment>(validationState)); } PostComment newComment; PostComment originalComment; using (TransactionScope transaction = new TransactionScope()) { originalComment = getComment(commentAddress); newComment = originalComment.Apply(commentInput, context.User.Cast <UserAuthenticated>()); newComment = blogsCommentRepository.Save(newComment, context.Site.ID, newComment.Post.BlogName, newComment.Post.Slug); invalidateCachedCommentForEdit(newComment, originalComment); transaction.Complete(); } PostSmallReadOnly postProxy = new PostSmallReadOnly(newComment.Post); CommentReadOnly newCommentProxy = new CommentReadOnly(newComment, absolutePathHelper.GetAbsolutePath(newComment)); CommentReadOnly originalCommentProxy = new CommentReadOnly(originalComment, absolutePathHelper.GetAbsolutePath(originalComment)); pluginEngine.ExecuteAll("CommentEdited", new { context, parent = postProxy, comment = newCommentProxy, commentOriginal = originalCommentProxy }); return(new ModelResult <PostComment>(newComment, validationState)); }
public ActionResult Remove(PostCommentAddress commentAddress, string returnUri) { //TODO: (erikpo) Check permissions if (commentService.RemoveComment(commentAddress)) { if (!string.IsNullOrEmpty(returnUri)) { return(new RedirectResult(returnUri)); } return(new JsonResult { Data = true }); } else { return(new JsonResult { Data = false }); } }
private PostComment getComment(PostCommentAddress commentAddress) { return(getComment(blogsCommentRepository.GetComment(context.Site.ID, commentAddress.BlogName, commentAddress.PostSlug, commentAddress.CommentSlug))); }
public bool ApproveComment(PostCommentAddress commentAddress) { return(changeState(commentAddress, EntityState.Normal, "CommentApproved")); }
public bool RemoveComment(PostCommentAddress commentAddress) { return(changeState(commentAddress, EntityState.Removed, "CommentRemoved")); }