示例#1
0
 public int Excluir(int id)
 {
     try
     {
         using (veiculosapiContext contexto = new veiculosapiContext())
         {
             Abastecimento abastecimento = contexto.Abastecimento.Where(p => p.Id == id).FirstOrDefault();
             contexto.Abastecimento.Remove(abastecimento);
             return(contexto.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
示例#2
0
 public int Alterar()
 {
     try
     {
         using (veiculosapiContext contexto = new veiculosapiContext())
         {
             Abastecimento abastecimento = contexto.Abastecimento.Where(p => p.Id == this.Id).FirstOrDefault();
             abastecimento.Km                = this.Km;
             abastecimento.Litro             = this.Litro;
             abastecimento.Valor             = this.Valor;
             abastecimento.Data              = this.Data;
             abastecimento.Posto             = this.Posto;
             abastecimento.UsuarioId         = this.UsuarioId;
             abastecimento.TipoCombustivelId = this.TipoCombustivelId;
             contexto.Abastecimento.Attach(abastecimento);
             return(contexto.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }