public async Task <PagedResult <Dtos.V10.ProductOut> > PagedQuery1Async( [FromRoute] Queries.V10.PagedProductQuery query) { var @out = await _mediator.SendAsync(query); return(@out); }
public async Task <PagedResult <Dtos.V10.ProductOut> > HandleAsync(Queries.V10.PagedProductQuery query, CancellationToken cancellationToken = new CancellationToken()) { query.Keyword = query.Keyword?.Trim(); PagedResult <Product> result; if (string.IsNullOrWhiteSpace(query.Keyword)) { result = await _dbContext.Set <Product>() .OrderByDescending(x => x.LastModificationTime) .PagedQueryAsync(query.Page, query.Limit); } else { result = await _dbContext.Set <Product>() .Where(x => x.Name.Contains(query.Keyword)) .OrderByDescending(x => x.LastModificationTime) .PagedQueryAsync(query.Page, query.Limit); } return(new PagedResult <Dtos.V10.ProductOut>(result.Page, result.Limit, result.Total, _objectAssembler.To <IEnumerable <Dtos.V10.ProductOut> >(result.Data))); }