Ejemplo n.º 1
0
        public async Task <string> AddIngredients([FromBody] IList <Ingredient> ingredients, Guid userID,
                                                  string userName)
        {
            await _ingredientService.AddIngredients(ingredients, userID, userName);

            return("Ok");
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 3
0
 public async Task Handle(NewIngredientEvent @event)
 {
     await _ingredientService.AddIngredients(@event);
 }