public async Task <IReadOnlyList <ProductDto> > GetProducts(GetProductsFilter filter) { var productsQuery = _dbContext.Products.AsQueryable(); if (filter.Ids != null) { productsQuery = productsQuery.Where(product => filter.Ids.Contains(product.Id)); } var products = await productsQuery.ToListAsync(); return(_mapper.Map <IReadOnlyList <ProductDto> >(products, opts => opts.Items.Add(Constants.OrderDate, filter.OrderDate == DateTime.MinValue ? DateTime.UtcNow : filter.OrderDate))); }
public async Task <IActionResult> GetProducts([FromQuery] GetProductsFilter filter) { return(Ok(await _productService.GetProducts(filter))); }