public static CommentInfo ConvertComment(Comment comment, IList<Comment> commentList)
        {
            var userID = comment.UserID;

            CommentInfo c = new CommentInfo
                {
                    CommentID = comment.ID.ToString(),
                    UserID = userID,
                    TimeStamp = comment.Datetime,
                    TimeStampStr = comment.Datetime.Ago(),
                    Inactive = comment.Inactive,
                    CommentBody = comment.Content,
                    UserFullName = DisplayUserSettings.GetFullUserName(userID),
                    UserAvatar = BookmarkingServiceHelper.GetHTMLUserAvatar(userID),
                    IsEditPermissions = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment),
                    IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment(),
                    UserPost = BookmarkingServiceHelper.GetUserInfo(userID).Title
                };

            var commentsList = new List<CommentInfo>();

            var childComments = GetChildComments(comment, commentList);
            if (childComments != null)
            {
                foreach (var item in childComments)
                {
                    commentsList.Add(ConvertComment(item, commentList));
                }
            }
            c.CommentList = commentsList;
            return c;
        }
 public BookmarkCommentWrapper(Comment comment)
 {
     CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(comment.UserID));
     Updated=Created = (ApiDateTime) comment.Datetime;
     Id = comment.ID;
     Text = comment.Content;
     if (!string.IsNullOrEmpty(comment.Parent))
         ParentId = new Guid(comment.Parent);
 }
예제 #3
0
		private static IList<Comment> GetChildComments(Comment c, IList<Comment> comments)
		{
			var children = new List<Comment>();
			var commentID = c.ID.ToString();
			foreach (var comment in comments)
			{
				if (commentID.Equals(comment.Parent))
				{
					children.Add(comment);
				}
			}
			return children;
		}
 private static IList<Comment> GetChildComments(Comment c, IList<Comment> comments)
 {
     var commentID = c.ID.ToString();
     return comments.Where(comment => commentID.Equals(comment.Parent)).ToList();
 }
예제 #5
0
 public BookmarkCommentWrapper AddBookmarkComment(long id, string content, Guid parentId)
 {
     var comment = new Comment()
                       {
                                 ID = Guid.NewGuid(),
                               BookmarkID = id,
                               Content = content,
                               Datetime = DateTime.UtcNow,
                               UserID = SecurityContext.CurrentAccount.ID,
                               Parent = parentId.ToString()
                           };
     BookmarkingDao.AddComment(comment);
     return new BookmarkCommentWrapper(comment);
 }
 private string GetOneCommentHtmlWithContainer(Comment comment)
 {
     return CommentsHelper.GetOneCommentHtmlWithContainer(
         Comments,
         BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments),
         comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase),
         false);
 }
        private string GetHTMLComment(string text, string commentID)
        {
            var comment = new Comment
                {
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            if (!String.IsNullOrEmpty(commentID))
            {
                comment = _serviceHelper.GetCommentById(commentID);

                comment.Parent = string.Empty;
            }
            comment.Content = HtmlUtility.GetFull(text);

            var defComment = new CommentsList();

            ConfigureComments(defComment);

            var ci = BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments);
            ci.IsEditPermissions = false;
            ci.IsResponsePermissions = false;

            var isRoot = string.IsNullOrEmpty(comment.Parent) || comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase);

            return CommentsHelper.GetOneCommentHtmlWithContainer(defComment, ci, isRoot, false);
        }
        public AjaxResponse AddComment(string parrentCommentID, long bookmarkID, string text, string pid)
        {
            var resp = new AjaxResponse { rs1 = parrentCommentID };

            var comment = new Comment
                {
                    Content = HtmlUtility.GetFull(text),
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            var parentID = Guid.Empty;
            try
            {
                if (!string.IsNullOrEmpty(parrentCommentID))
                {
                    parentID = new Guid(parrentCommentID);
                }
            }
            catch
            {
                parentID = Guid.Empty;
            }
            comment.Parent = parentID.ToString();
            comment.BookmarkID = bookmarkID;
            comment.ID = Guid.NewGuid();

            _serviceHelper.AddComment(comment);

            resp.rs2 = GetOneCommentHtmlWithContainer(comment);

            return resp;
        }
예제 #9
0
        public BookmarkCommentWrapper AddBookmarkComment(long id, string content, Guid parentId)
        {
            var bookmark = BookmarkingDao.GetBookmarkByID(id);
            if (bookmark == null) throw new ItemNotFoundException("bookmark not found");

            var comment = new Comment
                {
                    ID = Guid.NewGuid(),
                    BookmarkID = id,
                    Content = content,
                    Datetime = DateTime.UtcNow,
                    UserID = SecurityContext.CurrentAccount.ID,
                    Parent = parentId.ToString()
                };
            BookmarkingDao.AddComment(comment);
            return new BookmarkCommentWrapper(comment);
        }
예제 #10
0
 private static FeedComment ToFeedComment(Comment comment)
 {
     return new FeedComment(comment.UserID)
         {
             Id = comment.ID.ToString(),
             Description = HtmlSanitizer.Sanitize(comment.Content),
             Date = comment.Datetime
         };
 }
예제 #11
0
        private static Comment ToComment(object[] r)
        {
            var comment = new Comment
                {
                    Bookmark = new Bookmark
                        {
                            ID = Convert.ToInt64(r[0]),
                            URL = Convert.ToString(r[1]),
                            Name = Convert.ToString(r[2]),
                            Description = Convert.ToString(r[3]),
                            UserCreatorID = new Guid(Convert.ToString(r[4])),
                            Date = Convert.ToDateTime(Convert.ToString(r[5]))
                        }
                };

            if (r[6] != null)
            {
                comment.ID = new Guid(Convert.ToString(r[6]));
                comment.Content = Convert.ToString(r[7]);
                comment.UserID = new Guid(Convert.ToString(r[8]));
                comment.Datetime = Convert.ToDateTime(Convert.ToString(r[9]));
            }
            return comment;
        }
 public static bool PermissionCheckEditComment(Comment c)
 {
     return CommunitySecurity.CheckPermissions(new BookmarkPermissionSecurityObject(c.UserID, c.ID), BookmarkingBusinessConstants.BookmarkEditCommentAction);
 }