示例#1
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            text = HtmlUtility.GetFull(text);
            var messageEngine = Global.EngineFactory.GetMessageEngine();
            var resp          = new AjaxResponse {
                rs1 = commentID
            };

            var comment = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentID));

            comment.Content = text;

            var targetID = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);
            var target   = messageEngine.GetByID(targetID);

            if (target == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            var targetProject = target.Project;

            ProjectSecurity.DemandEditComment(targetProject, comment);

            Discussion = target;

            messageEngine.SaveOrUpdateComment(target, comment);
            MessageService.Send(HttpContext.Current.Request, MessageAction.DiscussionCommentUpdated, Discussion.Project.Title, Discussion.Title);

            resp.rs2 = text + CodeHighlighter.GetJavaScriptLiveHighlight(true);
            return(resp);
        }
示例#2
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            var taskEngine = Global.EngineFactory.GetTaskEngine();
            var comment    = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentID));

            comment.Content = text;

            var targetID = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);
            var target   = taskEngine.GetByID(targetID);

            if (target == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            var targetProject = target.Project;

            ProjectSecurity.DemandEditComment(targetProject, comment);

            taskEngine.SaveOrUpdateComment(target, comment);

            return(new AjaxResponse {
                rs1 = commentID, rs2 = text + CodeHighlighter.GetJavaScriptLiveHighlight(true)
            });
        }
示例#3
0
        public string RemoveComment(string commentID, string pid)
        {
            var comment       = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentID));
            var targetID      = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);
            var target        = Global.EngineFactory.GetTaskEngine().GetByID(targetID);
            var targetProject = target.Project;

            ProjectSecurity.DemandEditComment(targetProject, comment);
            ProjectSecurity.DemandRead(target);

            comment.Inactive = true;

            Global.EngineFactory.GetCommentEngine().SaveOrUpdate(comment);

            return(commentID);
        }
示例#4
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            var comment       = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentID));
            var targetID      = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);
            var target        = Global.EngineFactory.GetTaskEngine().GetByID(targetID);
            var targetProject = target.Project;

            comment.Content = text;

            ProjectSecurity.DemandEditComment(targetProject, comment);
            Global.EngineFactory.GetTaskEngine().SaveOrUpdateTaskComment(target, comment);

            return(new AjaxResponse {
                rs1 = commentID, rs2 = text + Web.Controls.CodeHighlighter.GetJavaScriptLiveHighlight(true)
            });
        }
示例#5
0
        public string RemoveComment(string commentID, string pid)
        {
            var commentEngine = Global.EngineFactory.GetCommentEngine();
            var comment       = commentEngine.GetByID(new Guid(commentID));
            var targetID      = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);
            var target        = Global.EngineFactory.GetTaskEngine().GetByID(targetID);
            var targetProject = target.Project;

            ProjectSecurity.DemandEditComment(targetProject, comment);
            ProjectSecurity.DemandRead(target);

            comment.Inactive = true;

            comment = commentEngine.SaveOrUpdate(comment);
            MessageService.Send(HttpContext.Current.Request, MessageAction.TaskCommentDeleted, target.Project.Title, target.Title);

            return(commentID);
        }
        public string UpdateComment(string commentid, string content)
        {
            var commentEngine = EngineFactory.CommentEngine;
            var comment       = commentEngine.GetByID(new Guid(commentid));

            comment.Content = content;

            var entity = commentEngine.GetEntityByTargetUniqId(comment);

            if (entity == null)
            {
                throw new Exception("Access denied.");
            }

            ProjectSecurity.DemandEditComment(entity.Project, comment);

            commentEngine.SaveOrUpdateComment(entity, comment);
            MessageService.Send(Request, MessageAction.TaskCommentUpdated, entity.Project.Title, entity.Title);

            return(HtmlUtility.GetFull(content));
        }
        public string RemoveProjectComment(string commentid)
        {
            var commentEngine = EngineFactory.CommentEngine;

            var comment = commentEngine.GetByID(new Guid(commentid)).NotFoundIfNull();

            comment.Inactive = true;

            var entity = commentEngine.GetEntityByTargetUniqId(comment);

            if (entity == null)
            {
                return("");
            }

            ProjectSecurity.DemandEditComment(entity.Project, comment);

            commentEngine.SaveOrUpdate(comment);
            MessageService.Send(Request, MessageAction.TaskCommentDeleted, MessageTarget.Create(comment.ID), entity.Project.Title, entity.Title);

            return(commentid);
        }