public int AddFoodRecipe(RecipeRequest recipeRequest) { var foodrecipeMap = GetMappingToFoodRecipe(recipeRequest); _recipeContext.FoodRecipes.Add(foodrecipeMap); var recipeIngredients = MapToRecipeIngredient(recipeRequest); if (recipeIngredients != null) { foodrecipeMap.RecipeIngredients.AddRange(recipeIngredients); } _recipeContext.SaveChanges(); return(foodrecipeMap.RecipeId); }
public int CreateRecipe(RecipeRequest recipeRequest) { var foodRecipe = new MapFoodRecipe(); var foodrecipeMap = foodRecipe.GetMappingToFoodRecipe(recipeRequest); _recipeContext.FoodRecipes.Add(foodrecipeMap); var map = new MapIngredients(_recipeContext); var recipeIngredients = map.MapToRecipeIngredient(recipeRequest); if (recipeIngredients != null) { foodrecipeMap.RecipeIngredients.AddRange(recipeIngredients); } var mapdirection = new MapDirections(); var directions = mapdirection.MapToRecipeDirections(recipeRequest); _recipeContext.RecipeDirection.AddRange(directions); var mapCuisine = new MapRecipeCuisine(_recipeContext); var recipeCuisine = mapCuisine.MapToRecipeCuisines(recipeRequest); _recipeContext.RecipeCuisine.AddRange(recipeCuisine); var mapMealtype = new MapMealType(_recipeContext); var recipeMealType = mapMealtype.MapToRecipeCuisines(recipeRequest); _recipeContext.RecipeMealType.AddRange(recipeMealType); var mapDishType = new MapDishType(_recipeContext); var recipeDishType = mapDishType.MapToRecipeDishType(recipeRequest); _recipeContext.RecipeDishType.AddRange(recipeDishType); var mapCookingStyle = new MapCookingStyle(_recipeContext); var recipeCookingStyle = mapCookingStyle.MapToRecipeCookingStyles(recipeRequest); _recipeContext.RecipeCookingStyle.AddRange(recipeCookingStyle); _recipeContext.SaveChanges(); return(foodrecipeMap.RecipeId); }