public void removeTransaction() { using (MyDBContext db = new MyDBContext()) { db.Transactions.Attach(this); db.Transactions.Remove(this); db.SaveChanges(); } }
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(); } } }
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(); } } }