Пример #1
0
        public List <RecipeRequest> GetFoodRecipeByIngredients(string ingredientName)
        {
            var ingredientId = GetIngredientId(ingredientName);

            if (ingredientId < 1)
            {
                return(new List <RecipeRequest>());
            }

            var foodRecipes = _recipeContext.RecipeIngredient.Where(x => x.IngredientId == ingredientId).ToList();

            if (foodRecipes.Equals(null))
            {
                return(new List <RecipeRequest>());
            }

            List <RecipeRequest> recipeRequests = new List <RecipeRequest>();

            foreach (var recipeItem in foodRecipes)
            {
                var recipe = new MapRecipe(_recipeContext);
                recipeRequests.Add(recipe.MapToRecipe(recipeItem.RecipeId));
            }
            return(recipeRequests);
        }
Пример #2
0
        public RecipeRequest GetFoodRecipe(string recipeName)
        {
            var foodRecipe = _recipeContext.FoodRecipes.FirstOrDefault(x => x.FoodName == recipeName);
            var recipe     = new MapRecipe(_recipeContext);

            if (foodRecipe != null)
            {
                return(recipe.MapToRecipe(foodRecipe.RecipeId));
            }
            return(new RecipeRequest());
        }
Пример #3
0
        public RecipeRequest GetFoodRecipe(int recipeId)
        {
            var recipe = new MapRecipe(_recipeContext);

            return(recipe.MapToRecipe(recipeId));
        }