Esempio n. 1
0
        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());
        }
Esempio n. 2
0
 public async Task <IEnumerable <Product> > Get([FromUri] GetProductsByAutoMapperQuery query)
 {
     return(await this.mediator.Send(query));
 }