public async Task AddClienteAsync(Cliente cliente) { try { using FleetManContext context = new FleetManContext(); context.Clientes.Add(cliente); await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task AddVeiculoAsync(Veiculo veiculo) { try { using FleetManContext context = new FleetManContext(); context.Veiculos.Add(veiculo); await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task AddMotoristaAsync(Motorista motorista) { try { using FleetManContext context = new FleetManContext(); context.Motoristas.Add(motorista); await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task UpdateVeiculoAsync(Veiculo veiculo) { try { using FleetManContext context = new FleetManContext(); AttachItem(veiculo, context); context.Entry(veiculo).State = EntityState.Modified; await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task UpdateClienteAsync(Cliente cliente) { try { using FleetManContext context = new FleetManContext(); AttachItem(cliente, context); context.Entry(cliente).State = EntityState.Modified; await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task UpdateMotoristaAsync(Motorista motorista) { try { using FleetManContext context = new FleetManContext(); AttachItem(motorista, context); context.Entry(motorista).State = EntityState.Modified; await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task RemoveVeiculoAsync(string placa) { try { using FleetManContext context = new FleetManContext(); Veiculo veiculo = await GetVeiculoAsync(placa); if (veiculo != null) { AttachItem(veiculo, context); context.Veiculos.Remove(veiculo); } await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task RemoveClienteAsync(string cnpj) { try { using FleetManContext context = new FleetManContext(); Cliente cliente = await GetClienteAsync(cnpj); if (cliente != null) { AttachItem(cliente, context); context.Clientes.Remove(cliente); } await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task RemoveMotoristaAsync(string cpf) { try { using FleetManContext context = new FleetManContext(); Motorista motorista = await GetMotoristaAsync(cpf); if (motorista != null) { AttachItem(motorista, context); context.Motoristas.Remove(motorista); } await context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }