コード例 #1
0
 public ApiResponse <RecipeViewModel> AddRecipe([FromBody] NewRecipeViewModel model)
 {
     try
     {
         return(ApiResponse <RecipeViewModel> .CreateResponse(true, "", _recipeService.AddRecipes(new Services.Message.AddRecipeRequest()
         {
             model = model
         }).recipe));
     }
     catch (BusinessRuleException ex)
     {
         return(ApiResponse <RecipeViewModel> .CreateResponse(false, ex.Message, null, rules : ex.brokenRules, code : HttpStatusCode.BadRequest));
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return(ApiResponse <RecipeViewModel> .CreateResponse(false, "An unexpected error occured.", null, code : HttpStatusCode.InternalServerError));
     }
 }