public void Should_Add_An_Ingredient_Successfully()
        {
            var ingredient = new NewIngredientViewModel();

            ingredient.Name = "Integration ingredient";

            var request = new AddIngredientRequest()
            {
                model = ingredient
            };
            var response = _ingredientService.AddIngredients(request);
        }
示例#2
0
 public ApiResponse <IngredientViewModel> AddRecipe([FromBody] NewIngredientViewModel model)
 {
     try
     {
         return(ApiResponse <IngredientViewModel> .CreateResponse(true, "", _ingredientService.AddIngredients(new Services.Message.AddIngredientRequest()
         {
             model = model
         }).ingredient));
     }
     catch (BusinessRuleException ex)
     {
         return(ApiResponse <IngredientViewModel> .CreateResponse(false, ex.Message, null, rules : ex.brokenRules, code : HttpStatusCode.BadRequest));
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return(ApiResponse <IngredientViewModel> .CreateResponse(false, "An unexpected error occured.", null, code : HttpStatusCode.InternalServerError));
     }
 }