public Account LoadAccount(string accountNumber) { using (var context = new AccountDBEntities()) { return(context.Accounts.SingleOrDefault(a => a.AccountNumber == accountNumber)); } }
public void Delete(string accountNumber) { using (var context = new AccountDBEntities()) { context.Accounts.Remove(LoadAccount(accountNumber)); } }
public void SaveAccount(Account account) { AccountDBEntities entities = new AccountDBEntities(); entities.Accounts.Attach(account); entities.Entry(account).State = EntityState.Modified; entities.SaveChanges(); }
public void Add(Account account) { using (var context = new AccountDBEntities()) { context.Accounts.Add(account); context.SaveChanges(); } }
public List <Account> List() { List <Account> accounts = new List <Account>(); using (var context = new AccountDBEntities()) { foreach (var account in context.Accounts) { accounts.Add(account); } } return(accounts); }