public Task <IReadOnlyList <PostListItem> > GetPagedPostsAsync(int pageSize, int pageIndex, Guid?categoryId = null) { if (pageSize < 1) { throw new ArgumentOutOfRangeException(nameof(pageSize), $"{nameof(pageSize)} can not be less than 1, current value: {pageSize}."); } if (pageIndex < 1) { throw new ArgumentOutOfRangeException(nameof(pageIndex), $"{nameof(pageIndex)} can not be less than 1, current value: {pageIndex}."); } var spec = new PostPagingSpec(pageSize, pageIndex, categoryId); return(_postRepository.SelectAsync(spec, p => new PostListItem { Title = p.Title, Slug = p.Slug, ContentAbstract = p.ContentAbstract, PubDateUtc = p.PostPublish.PubDateUtc.GetValueOrDefault(), Tags = p.PostTag.Select(pt => new Tag { NormalizedTagName = pt.Tag.NormalizedName, TagName = pt.Tag.DisplayName }).ToList() })); }
public Task <IReadOnlyList <PostDigest> > Handle(ListPostsQuery request, CancellationToken cancellationToken) { Helper.ValidatePagingParameters(request.PageSize, request.PageIndex); var spec = new PostPagingSpec(request.PageSize, request.PageIndex, request.CatId); return(_postRepo.SelectAsync(spec, PostDigest.EntitySelector)); }