Ejemplo n.º 1
0
        public ViewResult InsertPage(RecipeFormViewModelData recipe)
        {
            if (ModelState.IsValid)
            {
                RecipeItem newRecipe = new RecipeItem();
                newRecipe.RecipeName  = recipe.RecipeName;
                newRecipe.ServingSize = recipe.ServingSize;
                newRecipe.Description = recipe.Description;
                Ingredient newIngredient = new Ingredient();
                newIngredient.IngredientName = recipe.Ingredient;
                Equipment newEquipment = new Equipment();
                newEquipment.EquipmentName = recipe.Equipment;
                newRecipe.Instructions     = recipe.Instructions;

                repository.AddRecipe(newRecipe);
                repository.AddIngredient(newIngredient);
                repository.AddEquipment(newEquipment);
                repository.AddReview(new Review());
                return(View("DataPage", repository.Recipes));
            }
            else
            {
                return(View());
            }
        }