Exemplo n.º 1
0
        public static Recipe Create(string name,
                                    string description,
                                    Author.Author author,
                                    IEnumerable <RecipeIngredientDto> ingredients,
                                    IEnumerable <Ingredient.Ingredient> fullIngredients,
                                    IEnumerable <RecipeStepRequestDto> steps)
        {
            var recipeId = Guid.NewGuid().ToString();

            var recipeIngredients = MatchWithDbIngredients(ingredients, fullIngredients, recipeId);
            var recipeSteps       = steps
                                    .Select(x =>
                                            new RecipeStep.RecipeStep(
                                                recipeId,
                                                x.Position,
                                                x.ImageUrl,
                                                x.Description)
                                            ).ToList();

            var newRecipe = new Recipe(recipeId, name, description, author)
            {
                Ingredients = recipeIngredients,
                Steps       = recipeSteps
            };

            return(newRecipe);
        }
 public Author.Author postAuthor(Author.Author author)
 {
     return(postObjectAsync <Author.Author>("Authors/", author));
 }