예제 #1
0
        public List <RecipeAng> GenerateRecipeListFromCocktailIds(List <int> cocktailIds)
        {
            var result = new List <RecipeAng>();

            foreach (var id in cocktailIds)
            {
                var cocktailRecipeToAdd = new RecipeAng();
                var cocktail            = _cocktailRepo.GetCocktailById(id);
                cocktailRecipeToAdd.CocktailName = cocktail.Name;
                cocktailRecipeToAdd.ImgUrl       = "/Content/img/" + cocktail.ImgUrl + ".jpg";

                //get all ingredients
                var ingredients = _ciRepo.GetAllIngredientsByCocktailId(id);
                foreach (var ing in ingredients)
                {
                    cocktailRecipeToAdd.Ingredients.Add
                        (ing.Amount + " " + _ingredientRepo.GetIngredientById(ing.IngredientId).Name);
                }

                //get all recipe steps
                cocktailRecipeToAdd.RecipeSteps =
                    _recipeRepo.GetAllRecipeStepsByCocktail(id).Select(m => m.StepNumber + ". " + m.Text).ToList();

                //add recipe to the model
                result.Add(cocktailRecipeToAdd);
            }

            return(result.OrderBy(m => m.Ingredients.Count).ToList());
        }
예제 #2
0
        public void CanGetAllRecipesPerCocktail()
        {
            var recipes = repo.GetAllRecipeStepsByCocktail(1);

            Assert.AreEqual(recipes.Count, 4);
        }