Beispiel #1
0
        public async Task <IActionResult> SearchAction(string ingredient)
        {
            var products = await _foodFactsService.GetProductsByIngredientAsync(ingredient).ConfigureAwait(false);

            if (!products.Any())
            {
                var error = $"The products with the specified ingredient {ingredient} were not found.";

                return(NotFound(new { error }));
            }

            return(Ok(new { products }));
        }
Beispiel #2
0
        public async Task GetProducts_ByIngredient_NotEmpty()
        {
            var products = await _foodFactsService.GetProductsByIngredientAsync("egg", 5).ConfigureAwait(false);

            Assert.NotEmpty(products);
        }