public IActionResult CreateProduct([FromBody] CommandRegisterItem command, [FromServices] HandlerCatalogItem handler) { var request = handler.handle(command); if (request.HasError()) { return(BadRequest(request.Error())); } return(Ok(request.ResponseObj())); }
public IActionResult UpdateProduct([FromBody] CommandUpdateItem command, [FromServices] HandlerCatalogItem handler, int id) { if (id != command.Id) { return(BadRequest(new { Code = "400", Description = "O Id do parametro e do body estão divergentes" })); } var request = handler.handle(command); if (request.HasError()) { return(BadRequest(request.Error())); } return(Ok(request.ResponseObj())); }