Example #1
0
 public virtual Task <IPagedList <TopicInfoView> > GetNewTopicsAsync(MaterialsMultiCatShowOptions options,
                                                                     int maxPages)
 {
     return(db.MaterialsVisible.GetPagedListMaxAsync(
                x => new TopicInfoView
     {
         Id = x.Id,
         Title = x.Title,
         SubTitle = x.SubTitle,
         CommentsCount = x.CommentsCount,
         AuthorName = x.Author.UserName,
         AuthorAvatar = x.Author.Avatar,
         PublishDate = x.PublishDate,
         LastCommentId = x.LastCommentId,
         LastCommentPublishDate = x.LastCommentId.HasValue ? (DateTime?)x.LastComment.PublishDate : null,
         CategoryName = x.Category.Name,
         CategoryTitle = x.Category.Title,
         LastCommentAuthorName = x.LastComment.Author.UserName,
         LastCommentAuthorAvatar = x.LastComment.Author.Avatar,
         IsCommentsBlocked = x.IsCommentsBlocked
     },
                x => options.CategoriesIds.Contains(x.CategoryId),
                x => x.OrderByDescending(y => y.LastActivity),
                options.Page,
                options.PageSize,
                maxPages));
 }
        public virtual async Task <IPagedList <PostView> > GetPostsFromMultiCategoriesAsync(
            MaterialsMultiCatShowOptions options)
        {
            var rez = await db.MaterialsVisible.GetPagedListAsync(
                x => new PostView
            {
                Id                = x.Id,
                Title             = x.Title,
                Preview           = x.Text,
                CommentsCount     = x.CommentsCount,
                AuthorName        = x.Author.UserName,
                AuthorLink        = x.Author.Link,
                AuthorAvatar      = x.Author.Avatar,
                PublishDate       = x.PublishDate,
                CategoryName      = x.Category.Name,
                CategoryTitle     = x.Category.Title,
                IsCommentsBlocked = x.IsCommentsBlocked
            },
                x => options.CategoriesIds.Contains(x.CategoryId),
                x => x.OrderByDescending(y => y.PublishDate),
                options.Page,
                options.PageSize);

            foreach (var postView in rez.Items)
            {
                var textLength = postView.Preview.Length;
                postView.Preview =
                    MakePreview.HtmlFirstImage(new HtmlParser().Parse(postView.Preview), options.PreviewSize);
                postView.HasMoreText = postView.Preview.Length != textLength;
            }

            return(rez);
        }
Example #3
0
 public virtual Task <IPagedList <ArticleInfoView> > GetArticlesFromMultiCategoriesAsync(
     MaterialsMultiCatShowOptions options)
 {
     return(db.Materials.Where(x => x.DeletedDate == null && !x.IsHidden).GetPagedListAsync(
                x => new ArticleInfoView
     {
         Id = x.Id,
         Name = x.Name,
         Title = x.Title,
         Description = x.SubTitle,
         CommentsCount = x.CommentsCount,
         AuthorName = x.Author.UserName,
         PublishDate = x.PublishDate,
         CategoryName = x.Category.Name,
         CategoryTitle = x.Category.Title,
         IsCommentsBlocked = x.IsCommentsBlocked
     },
                x => options.CategoriesIds.Contains(x.CategoryId),
                x => x.OrderByDescending(y => y.PublishDate),
                options.Page,
                options.PageSize));
 }
Example #4
0
 public virtual Task <IPagedList <PostView> > GetPostsFromMultiCategoriesAsync(MaterialsMultiCatShowOptions options)
 {
     return(db.MaterialsVisible.GetPagedListAsync(
                x => new PostView
     {
         Id = x.Id,
         Title = x.Title,
         Preview = x.Preview,
         CommentsCount = x.CommentsCount,
         AuthorName = x.Author.UserName,
         AuthorLink = x.Author.Link,
         AuthorAvatar = x.Author.Avatar,
         PublishDate = x.PublishDate,
         CategoryName = x.Category.Name,
         CategoryTitle = x.Category.Title,
         HasMoreText = x.Text.Length != x.Preview.Length,
         IsCommentsBlocked = x.IsCommentsBlocked
     },
                x => options.CategoriesIds.Contains(x.CategoryId),
                x => x.OrderByDescending(y => y.PublishDate),
                options.Page,
                options.PageSize));
 }