Пример #1
0
        private FilterResult BuildResponse(MockyResponse item, FilterQuery query)
        {
            _logger.LogInformation($"Build response...");
            var result = new FilterResult();

            if (item != null && item.Products.Any())
            {
                result.FilterOptions = SetFilterOptions(item.Products);
                var products = FilterProducts(item.Products, query.maxprice, query.size);

                result.Products = products.Select(t => new Product()
                {
                    Title       = t.Title,
                    Price       = t.Price,
                    Sizes       = t.Sizes,
                    Description = SetHighlight(t.Description, query.highlight)
                }).ToList();
            }

            return(result);
        }
Пример #2
0
 public async Task <FilterResult> FilterProducts(FilterQuery query)
 {
     _logger.LogInformation($"Search products...");
     return(BuildResponse(await _mockyService.GetProducts(), query));
 }