コード例 #1
0
        public async Task <IActionResult> AddRecipe([FromBody] SaveRecipeDTO recipeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _recipeService.AddRecipeAsync(recipeDTO);

            return(Ok(result));
        }
コード例 #2
0
        public async Task <IActionResult> AddRecipe(Recipe newRecipe)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }


            var successful = await recipeService.AddRecipeAsync(newRecipe);

            if (!successful)
            {
                return(BadRequest("Could not add recipe"));
            }
            return(RedirectToAction("Index"));
        }