public IEnumerable <ProductVm> Handle(GetProductsByAutoMapperQuery command) { IQueryable <Product> products = this._database.Products; if (command.CategoryId.HasValue) { products = products.Where(p => p.CategoryId == command.CategoryId); } return(products .OrderBy(p => p.CreationDate) .Skip((command.Page - 1) * command.Take) .Take(command.Take) .ProjectTo <ProductVm>() .ToList()); }
public async Task <IEnumerable <Product> > Get([FromUri] GetProductsByAutoMapperQuery query) { return(await this.mediator.Send(query)); }