Example #1
0
        public async Task <GetProductsListSummary> GetSummaryList(string category)
        {
            var list = await _context.GetItemsFromCategory(category)
                       .ProjectTo <ProductSummaryItem>(_config)
                       .ToListAsync();

            var response = new GetProductsListSummary
            {
                Data     = list,
                Category = category,
                Count    = list.Count()
            };

            return(response);
        }
Example #2
0
        public async Task <ActionResult> GetProducts([FromQuery] string category = null)
        {
            if (category == null)
            {
                GetProductsResponse response = await _products.GetSummary();

                return(Ok(response));
            }
            else
            {
                GetProductsListSummary response = await _products.GetSummaryList(category);

                return(Ok(response));
            }
        }