示例#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);
        }
示例#2
0
        public TopicWithCommentsClient ToTopicWithCommentsClient(TopicWithComments topicWithComments)
        {
            TopicWithCommentsClient topicWithCommentsClient = new TopicWithCommentsClient();

            topicWithCommentsClient.PageComments = new PageListClient <CommentClient>(topicWithComments.Comments, topicWithComments.Comments.Count);

            foreach (var comment in topicWithComments.Comments)
            {
                topicWithCommentsClient.PageComments.Models.Add(_commentDriver.ToClient(comment));
            }
            topicWithCommentsClient.Topic = ToClient(topicWithComments.Topic, excludeProperties: new string[] { "Comments" });

            return(topicWithCommentsClient);
        }