Exemplo n.º 1
0
        public async Task <IList <PostEntry> > GetContentCommentExtPostEntry(Guid conId, int skipCount, int pageSize)
        {
            //通过cate 名找到话题
            var postEntryMapCategory = await ContentAccessor.ListOrderByDescendingAsync <ContentPostEntryMapping>(x => x.Id == conId);

            var postEntryList = await ContentAccessor.ListOrderByDescendingAsync <PostEntry>(x => postEntryMapCategory.Any(c => c.PostEntryId == x.Id), skipCount, pageSize, "UserAccountEntry");

            return(postEntryList);
        }
Exemplo n.º 2
0
        public async Task <Tuple <IList <Categories>, int> > GetCategoryByTagName(string tagName, int pageSkip, int pageSize)
        {
            var categoryList = await ContentAccessor.ListOrderByDescendingAsync <Categories>(x => x.Status != ContentStatus.Close &&
                                                                                             x.ContentList != null &&
                                                                                             x.ContentList.Count > 0 &&
                                                                                             x.Tags.Any(c => c.Name == tagName)
                                                                                             , pageSkip, pageSize, "MediaResource");

            await ResetCategoryCoverImg(categoryList);

            var count = await ContentAccessor.Count <Categories>(x => x.Status != ContentStatus.Close &&
                                                                 x.ContentList != null &&
                                                                 x.ContentList.Count > 0 &&
                                                                 x.Tags.Any(c => c.Name == tagName));

            return(Tuple.Create(categoryList, count));
        }
Exemplo n.º 3
0
        public async Task <List <PostEntryOutputViewModel> > GetCategoryCommentExtPostEntry(Guid cateId, int skipCount, int pageSize)
        {
            //通过cate 名找到话题
            var postEntryMapCategory = await ContentAccessor.ListOrderByDescendingAsync <CategoryPostEntryMapping>(x => x.CategoryId == cateId);

            var postEntryList = await ContentAccessor.ListOrderByDescendingAsync <PostEntry>(x => postEntryMapCategory.Any(c => c.PostEntryId == x.Id), skipCount, pageSize, "UserAccountEntry", "UserAccountEntry.Profile");

            //var postentrySubComments = await ContentAccessor.All<PostEntry>().Where(x => postEntryList.Select(c => c.Id).Any(c => c == x.Id))
            //    .Include("PostEntryCommentList.UserAccount")
            //    .Select(x => new
            //    {
            //        PostId = x.Id,
            //        SubComments = x.PostEntryCommentList.Select(c => new
            //        {
            //             c
            //             c.CreateTime
            //        }).Take(2).OrderByDescending(c => c.CreateTime).ToList(),
            //        SubCommentsNum = x.PostEntryCommentList.Count()
            //    }).ToListAsync();
            var postentrySubComments = ContentAccessor.All <PostEntryComments>()
                                       .Where(x => postEntryList.Select(c => c.Id).Any(c => c == x.PostEntryId))
                                       .Include("UserAccount")
                                       .Include("ParentComment")
                                       .Include("ParentComment.UserAccount")
                                       .OrderByDescending(x => x.CreateTime)
                                       .Take(2)
                                       .GroupBy(x => x.PostEntryId)
                                       .ToList();
            //var postentrySubCommentNum = new Dictionary<Guid, int>();
            //postEntryList.ToList().ForEach(item =>
            //{

            //});
            var postentrtSubCommentsNum = await ContentAccessor.All <PostEntry>()
                                          .Where(x => postEntryList.Select(c => c.Id).Any(c => c == x.Id))
                                          .Select(x => new
            {
                x.Id,
                Count = x.PostEntryCommentList.Count()
            })
                                          .ToListAsync();



            var postEntryOutput = new List <PostEntryOutputViewModel>();

            postEntryList.ToList().ForEach(item =>
            {
                var subComments   = postentrySubComments.FirstOrDefault(x => x.Key == item.Id)?.ToList();
                var subCommentNum = postentrtSubCommentsNum.FirstOrDefault(x => x.Id == item.Id)?.Count ?? 0;
                postEntryOutput.Add(new PostEntryOutputViewModel
                {
                    Id      = item.Id,
                    LikeSum = item.LikeSum,
                    Order   = item.Order,
                    PostEntryCommentList    = subComments,
                    PostEntryCommentListNum = subCommentNum,
                    PostEntryTopic          = item.PostEntryTopic,
                    TextContent             = item.TextContent,
                    TimeStamp        = item.TimeStamp,
                    UserAccountEntry = item.UserAccountEntry
                });
            });
            return(postEntryOutput);
        }
Exemplo n.º 4
0
 public async Task <IList <ContentEntry> > GetNews(int skipCount, int pageSize)
 {
     //var targetTags = await ContentAccessor.ListOrderByDescendingAsync<Tags>(x => x.Name == "资讯");
     return(await ContentAccessor.ListOrderByDescendingAsync <ContentEntry>(x => x.Category.Name == "资讯", skipCount, pageSize, "MediaResource"));
 }