Example #1
0
 public async Task AddClienteAsync(Cliente cliente)
 {
     try
     {
         using FleetManContext context = new FleetManContext();
         context.Clientes.Add(cliente);
         await context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #2
0
 public async Task AddVeiculoAsync(Veiculo veiculo)
 {
     try
     {
         using FleetManContext context = new FleetManContext();
         context.Veiculos.Add(veiculo);
         await context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
 public async Task AddMotoristaAsync(Motorista motorista)
 {
     try
     {
         using FleetManContext context = new FleetManContext();
         context.Motoristas.Add(motorista);
         await context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
 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;
     }
 }
Example #5
0
 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;
     }
 }
Example #6
0
 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;
     }
 }
Example #7
0
        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;
            }
        }
Example #8
0
        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;
            }
        }
Example #9
0
        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;
            }
        }