Ejemplo n.º 1
0
 public void removeTransaction()
 {
     using (MyDBContext db = new MyDBContext())
     {
         db.Transactions.Attach(this);
         db.Transactions.Remove(this);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void removeInvoice()
 {
     using (MyDBContext db = new MyDBContext())
     {
         var transactions = db.Transactions.Where(x => x.invoiceId == invoiceId);
         db.Invoices.Attach(this);
         db.Invoices.Remove(this);
         db.SaveChanges();
         foreach (var transaction in transactions)
         {
             transaction.removeTransaction();
         }
     }
 }
Ejemplo n.º 3
0
 public void removeCustomer()
 {
     using (MyDBContext db = new MyDBContext())
     {
         var invoices = db.Invoices.Where(x => x.customerId == customerId);
         db.Customers.Attach(this);
         db.Customers.Remove(this);
         db.SaveChanges();
         foreach (var invoice in invoices)
         {
             invoice.removeInvoice();
         }
     }
 }