public ActionResult <Recipe> CreateRecipe([FromBody] Recipe newRecipe) { try { Recipe recipe = _service.CreateRecipe(newRecipe); return(Ok(recipe)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Create(RecipeCreateModel createRecipe) { if (ModelState.IsValid) { var recipe = ModelConverter.ConvertFromCreateModel(createRecipe); RecipesService.CreateRecipe(recipe); return(RedirectToAction("ModifyOverview")); } else { return(View(createRecipe)); } }