public Customer LoadCustomer(int ID) { using (var context = new SGBankEntities()) { return(context.Customers.SingleOrDefault(c => c.ID == ID)); } }
public Account LoadAccount(string AccountNumber) { using (var context = new SGBankEntities()) { return(context.Accounts.SingleOrDefault( a => a.AccountNumber == AccountNumber)); } }
public void SaveAccount(Account account) { using (var context = new SGBankEntities()) { context.Accounts.Attach(account); context.Entry(account).State = EntityState.Modified; context.SaveChanges(); } }
public void DeleteAccount(string accountNumber) { using (var context = new SGBankEntities()) { Account accountToDelete = context.Accounts.SingleOrDefault( a => a.AccountNumber == accountNumber); context.Accounts.Attach(accountToDelete); context.Accounts.Remove(accountToDelete); context.SaveChanges(); } }