Example #1
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = commentID;

            Guid?id = null;

            try
            {
                if (!String.IsNullOrEmpty(commentID))
                {
                    id = new Guid(commentID);
                }
            }
            catch
            {
                return(new AjaxResponse());
            }

            BlogsEngine engine = BasePage.GetEngine();

            var comment = engine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new ApplicationException("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment);

            comment.Content = text;

            var post = engine.GetPostById(comment.PostId);

            engine.UpdateComment(comment, post);

            resp.rs2 = text + Web.Controls.CodeHighlighter.GetJavaScriptLiveHighlight(true);

            return(resp);
        }