Example #1
0
 public static void Deposit(int accountNumber, double amount)
 {
     using (var db = new BankModel())
     {
         var account = db.Accounts.Where(a => a.AccountNumber == accountNumber).First();
         var original = account;
         account.Deposit(amount);
         db.Entry(original).CurrentValues.SetValues(account);
         db.SaveChanges();
     }
 }
Example #2
0
 public static decimal Deposit(int accountNumber, decimal amount )
 {
     using (var db = new BankModel())
     {
         var account = db.Accounts.Where(a => a.AccountNumber == accountNumber).First();
         var original = account;
         account.Deposit(amount);
         db.Entry(original).CurrentValues.SetValues(account);
         var transactionSuccess = CreateTransaction(DateTime.Now, "Deposit", amount, accountNumber, TransactionType.Credit);
         if (transactionSuccess)
         {
             db.SaveChanges();
         }
         return account.Balance;
     }
 }
Example #3
0
 public static void UpdateAccount(Account account)
 {
     using (var db = new BankModel())
     {
         var foundAccount = db.Accounts.Where(a => a.AccountNumber == account.AccountNumber).First();
         account.Balance = foundAccount.Balance;
         db.Entry(foundAccount).CurrentValues.SetValues(account);
         db.SaveChanges();
     }
 }