Exemple #1
0
        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);
        }
Exemple #2
0
 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()
     });
 }
Exemple #3
0
 public ActionResult <Guid> Create(RecipeNewModel recipe)
 {
     return(recipeFacade.Create(recipe));
 }
Exemple #4
0
 public ActionResult <Guid> Create(RecipeNewModel ingredient)
 {
     return(recipeFacade.Create(ingredient));
 }
Exemple #5
0
 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));
 }
Exemple #6
0
 public async Task <Guid> InsertAsync(RecipeNewModel recipeNewModel)
 {
     return(await _recipeClient.RecipePostAsync("3", "cs", recipeNewModel));
 }