public async void RemoverMotoristaPorId(long?id) { try { bool confirm = await Task.Run(() => { Motorista motorista = ObterMotoristaPorId(id); if (motorista.Estado == EstadosDeMotorista.EM_VIAGEM) { throw new Exception("Motorista se encontra em viagem"); } return(true); }); if (confirm) { Context.RemoverMotoristaPorId(id); } } catch (Exception ex) { throw ex; } }