public async Task <IActionResult> CreateRecipe([FromBody] NewRecipeDTO recipe) { if (recipe == null || recipe.Ingredients == null || recipe.Steps == null || recipe.Tags == null) { return(BadRequest()); } var userId = Guid.Parse(User.FindFirstValue(KnownClaims.UserId)); var ingredients = recipe.Ingredients.Select(i => Ingredient.Create(i.Name, i.Quantity)).ToList(); var steps = recipe.Steps.Select(s => Step.Create(s.Duration, s.Description)).ToList(); var tags = recipe.Tags.Select(t => Tag.Create(t.Name)).ToList(); await recipesService.CreateAsync( userId, recipe.Title, recipe.IsPrivate, recipe.Description, recipe.Image, recipe.Duration, recipe.Servings, recipe.Notes, ingredients, steps, tags ); return(new StatusCodeResult((int)HttpStatusCode.Created)); }