public ActionResult Cocktails()
        {
            var model = new AdminCocktailsVM();

            model.Populate(_ingredientRepo.GetAllIngredients());

            return(View(model));
        }
        public ActionResult Cocktails(AdminCocktailsVM model)
        {
            if (ModelState.IsValid)
            {
                //add cocktail data to cocktail table
                var cocktailAdded = _cocktailRepo.AddCocktail(new Cocktail
                {
                    Name   = model.Name,
                    ImgUrl = model.ImgUrl
                });

                //add cocktail/ingredient combo data to that table
                foreach (var ingredient in model.SelectedIngredients)
                {
                    _ciRepo.AddCocktailIngredient(new CocktailIngredient
                    {
                        CocktailId   = cocktailAdded.CocktailId,
                        IngredientId = ingredient.Id,
                        Amount       = ingredient.Amount
                    });
                }

                //add recipe data to recipe table
                foreach (var step in model.RecipeSteps)
                {
                    _recipeRepo.AddRecipe(new Recipe
                    {
                        CocktailId = cocktailAdded.CocktailId,
                        StepNumber = step.RecipeStepNumber,
                        Text       = step.Text
                    });
                }

                //redirect to admin home
                return(View("Index"));
            }

            //otherwise something went wrong, send back to view
            return(View(model));
        }