Esempio n. 1
0
        public void SaveAccount(Account account)
        {
            using (var context = new SGBankEntities())
            {
                context.Accounts.Attach(account);

                context.Entry(account).State = EntityState.Modified;

                context.SaveChanges();
            }
        }
Esempio n. 2
0
        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();
            }
        }