public async Task <PaginatedResult <CatalogItemDto> > Handle(CatalogItemsPaginatedQuery request, CancellationToken cancellationToken)
        {
            var totalItems = await _catalogItemRepository.GetAll()
                             .LongCountAsync();

            var itemsOnPage = await _catalogItemRepository.GetAll()
                              .Select(c => new CatalogItemDto(c))
                              .OrderBy(c => c.Name)
                              .Skip(request.Paginated.PageSize * request.Paginated.PageIndex)
                              .Take(request.Paginated.PageSize)
                              .ToListAsync();

            return(new PaginatedResult <CatalogItemDto>(request.Paginated.PageIndex, request.Paginated.PageSize, totalItems, itemsOnPage));
        }
Esempio n. 2
0
 public async Task <IEnumerable <CatalogItem> > Index()
 {
     return(await _catalogItemRepository.GetAll());
 }