public async Task <IActionResult> GetCatalog( [FromQuery] GetCatalogDto getCatalog) { _logger.LogThisMethod(); var products = await _catalogService.GetCatalogPageAsync(getCatalog); return(Ok(products)); }
public async Task <IEnumerable <ProductDto> > GetCatalogPageAsync(GetCatalogDto getCatalog) { var elems2Skip = (getCatalog.Page - 1) * getCatalog.MaxNumElem; // skip n pages var result = await _context.Products .OrderByDescending(p => p.LastUpdated) .Skip(elems2Skip) .Take(getCatalog.MaxNumElem) .ToArrayAsync(); return(_mapper.Map <IEnumerable <ProductDto> >(result)); }