private bool changeState(ScheduleItemCommentAddress commentAddress, EntityState state, string pluginEventName)
        {
            bool commentStateChanged    = false;
            ScheduleItemComment 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 ScheduleItemSmallReadOnly(comment.ScheduleItem), comment = new CommentReadOnly(comment, absolutePathHelper.GetAbsolutePath(comment)) });
            }

            return(commentStateChanged);
        }
示例#2
0
        public ActionResult Remove(ScheduleItemCommentAddress 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 ScheduleItemComment getComment(ScheduleItemCommentAddress scheduleItemAddress)
 {
     return(getComment(conferencesCommentRepository.GetComment(context.Site.ID, scheduleItemAddress.EventName, scheduleItemAddress.ScheduleItemSlug, scheduleItemAddress.CommentSlug)));
 }
 public bool ApproveComment(ScheduleItemCommentAddress commentAddress)
 {
     return(changeState(commentAddress, EntityState.Normal, "CommentApproved"));
 }
 public bool RemoveComment(ScheduleItemCommentAddress commentAddress)
 {
     return(changeState(commentAddress, EntityState.Removed, "CommentRemoved"));
 }