public async Task <Pedido> UpdatePedidoAsync(string userId, int id, Pedido pedido) { if (id != pedido.Id) { throw new NotFoundItemException($"not found pedido with id:{id}"); } await validateUserId(userId); pedido.UsuarioId = userId; var pedidoEntity = mapper.Map <PedidoEntity>(pedido); ARBRepository.UpdatePedidoAsync(pedidoEntity); if (await ARBRepository.SaveChangesAsync()) { return(mapper.Map <Pedido>(pedidoEntity)); } throw new Exception("there were an error with the BD"); }