Esempio n. 1
0
        //get single topic with its posts on paging
        public TopicWithComments GetTopicWithComments(Guid topicId, int pageNumber, int CommentsPerPage)
        {
            TopicWithComments topicWithComments = new TopicWithComments();

            if (topicId == Guid.Empty)
            {
                return(null);
            }
            Expression <Func <ContentComment, bool> > predicate = x => x.TopicId == topicId && !x.IsHidden && !x.IsSpam;

            topicWithComments.Comments = _commentWork.Paging(pageNumber, CommentsPerPage, "CreateTime desc", predicate, new string[] { "Topic", "Topic.User", "Topic.FirstComment", "Topic.Tags", "Topic.Tags.Category" });

            if (topicWithComments.Comments.Count > 0)
            {
                topicWithComments.Topic = topicWithComments.Comments[0].Topic;
            }
            else
            {
                topicWithComments.Topic = Get(topicId, new string[] { "Tags", "Tags.Category" });
            }



            return(topicWithComments);
        }
Esempio n. 2
0
        public PageListClient <CommentClient> PagingMyClientComments(int pageNumber, int pageSize, string sort)
        {
            Expression <Func <ContentComment, bool> > predicate = PredicateBuilder.True <ContentComment>();

            predicate = predicate.And(x => x.UserId == SecurityManager.CurrentUser.UserId);
            predicate = predicate.Expand();

            var pageComments = _commentWork.Paging(pageNumber, pageSize, sort, predicate, new string[] { "Topic" });
            PageListClient <CommentClient> page = new PageListClient <CommentClient>(pageComments, pageComments.Count);

            foreach (var comment in pageComments)
            {
                page.Add(ToClient(comment, excludeProperties: new string[] { "Vote", "Topic.SubTitle" }));
            }

            return(page);
        }