Exemplo n.º 1
0
 public bool Inserir(Gasto gasto)
 {
     using (var db = new GastosContext())
     {
         if (db.Database.Connection != null)
         {
             db.Gastos.Add(gasto);
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 2
0
 public bool Excluir(int id)
 {
     using (GastosContext db = new GastosContext())
     {
         if (db.Database.Connection != null)
         {
             Gasto gasto = db.Gastos.FirstOrDefault(a => a.Id == id);
             db.Gastos.Remove(gasto);
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 3
0
 public bool Atualizar(Gasto gasto)
 {
     using (GastosContext db = new GastosContext())
     {
         if (db.Database.Connection != null)
         {
             db.Gastos.Attach(gasto);
             db.Entry(gasto).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }