public List <Product> FilterCarsOnPrice(decimal?lowerBound, decimal?upperBound) { var productsByCategory = _productRepository.GetProductsByCategory("Cars"); _carRepository.GetCars(); List <Product> filteredProducts; if (upperBound == null) { filteredProducts = productsByCategory.Where(p => p.Price >= lowerBound).ToList(); } else if (lowerBound == null) { filteredProducts = productsByCategory.Where(p => p.Price <= upperBound).ToList(); } else { filteredProducts = productsByCategory.Where(p => p.Price >= lowerBound && p.Price <= upperBound) .ToList(); } foreach (Product product in filteredProducts) { product.Specifications = _specificationRepository.FindSpecificationsForProduct(product.Id); } return(filteredProducts); }