public Guid Create(RecipeNewModel recipe) { var recipeEntity = mapper.Map <RecipeEntity>(recipe); recipeRepository.Insert(recipeEntity); foreach (var ingredientAmount in recipeEntity.IngredientAmounts) { ingredientAmount.RecipeId = recipeEntity.Id; ingredientAmountRepository.Insert(ingredientAmount); } return(recipeEntity.Id); }
public RecipeEntity MapRecipeNewModelToEntity(RecipeNewModel recipeNewModel) { return(new RecipeEntity { Id = new Guid(), Name = recipeNewModel.Name, Directions = recipeNewModel.Directions, Servings = recipeNewModel.Servings, RecipeWasAdded = DateTime.Today, PrepTime = recipeNewModel.PrepTime, CookTime = recipeNewModel.CookTime, AdditionalTime = recipeNewModel.AdditionalTime, FoodCategory = recipeNewModel.FoodCategory, FoodSpecialDiet = recipeNewModel.FoodSpecialDiet, DegreeOfDifficulty = recipeNewModel.DegreeOfDifficulty, Author = MapAuthorDetailModelToEntity(recipeNewModel.Author), NutritionInfo = MapNutritionInfoNewModelToEntity(recipeNewModel.NutritionInfo), RecipeIngredients = recipeNewModel.Ingredients == null ? null : recipeNewModel.Ingredients.Select(MapRecipeIngredientNewModelToEntity).ToList() }); }
public ActionResult <Guid> Create(RecipeNewModel recipe) { return(recipeFacade.Create(recipe)); }
public ActionResult <Guid> Create(RecipeNewModel ingredient) { return(recipeFacade.Create(ingredient)); }
public async Task <Guid> InsertAsync(RecipeNewModel recipeNewModel, string version = null, string culture = null) { version ??= apiOptions.Value.Version; culture ??= webOptions.Value.DefaultCulture; return(await _recipeClient.RecipePostAsync(version, culture, recipeNewModel)); }
public async Task <Guid> InsertAsync(RecipeNewModel recipeNewModel) { return(await _recipeClient.RecipePostAsync("3", "cs", recipeNewModel)); }