public CommentInfo(List <Node> comments, List <Node> likesForComments, string markupStr) { var commentsMarkup = new StringBuilder(); var hiddenComments = new StringBuilder(); var index = 0; foreach (var comment in comments) { var likesForComment = likesForComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == comment.Path).ToList(); var commentGc = comment as GenericContent; var commentLikeInfo = new LikeInfo(likesForComment, commentGc.Id); var commentMarkup = WallHelper.GetCommentMarkup(markupStr, commentGc.CreationDate, commentGc.CreatedBy as User, commentGc.Description, commentGc.Id, commentLikeInfo, comment); // if it is one of the last two comments, add it to visible comments list, otherwise to hidden comments list if (index < comments.Count - 2) { hiddenComments.Append(commentMarkup); } else { commentsMarkup.Append(commentMarkup); } index++; } CommentsMarkup = commentsMarkup.ToString(); HiddenCommentsMarkup = hiddenComments.ToString(); CommentCount = comments.Count; }
public CommentInfo(int itemId) { var comments = new StringBuilder(); var hiddenComments = new StringBuilder(); var commentsResult = DataLayer.GetComments(itemId); if (commentsResult == null) { return; } var index = 0; foreach (var comment in commentsResult.Nodes) { var commentGc = comment as GenericContent; var commentLikeInfo = new LikeInfo(commentGc.Id); var commentMarkup = WallHelper.GetCommentMarkup(commentGc.CreationDate, commentGc.CreatedBy as User, commentGc.Description, commentGc.Id, commentLikeInfo, comment); // if it is one of the last two comments, add it to visible comments list, otherwise to hidden comments list if (index < commentsResult.Count - 2) { hiddenComments.Append(commentMarkup); } else { comments.Append(commentMarkup); } index++; } CommentsMarkup = comments.ToString(); HiddenCommentsMarkup = hiddenComments.ToString(); CommentCount = commentsResult.Count; }
public ActionResult CreateComment(string postId, string contextPath, string text, string rnd) { if (string.IsNullOrEmpty(text)) { return(null); } AssertPermission(); SetCurrentWorkspace(contextPath); var comment = DataLayer.CreateComment(postId, contextPath, text); var commentMarkup = WallHelper.GetCommentMarkup(comment.CreationDate, ContentRepository.User.Current as User, text, comment.Id, new LikeInfo(), comment); return(Json(commentMarkup, JsonRequestBehavior.AllowGet)); }