Ejemplo n.º 1
0
        public static IEnumerable<Account> GetAllAccountsBySSN(int ssn)
        {
            var db = new BankModel();

            //return accounts.Where(a => a.SSN == ssn);
            return db.Accounts.Where(a => a.SSN == ssn);
        }
Ejemplo n.º 2
0
 public static void CreateAccount(Account account)
 {
     using (var db = new BankModel())
     {
         db.Accounts.Add(account);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public static Account GetAccountByAccountNumber(int accountNumber)
 {
     using (var db = new BankModel())
     {
         var userAccount = db.Accounts.Where(account => account.AccountNumber == accountNumber).FirstOrDefault();
         return userAccount;
     }
 }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Get all the accounts for the user
 /// </summary>
 /// <param name="SSN">Social security number of the account holder</param>
 /// <returns>All the accounts of the user</returns>
 public static Account[] GetAllAccountsBySSN(int SSN)
 {
     //Connects to the database
     //BankModel db = new BankModel();
     using (var db = new BankModel())
     {
         var userAccounts = db.Accounts.Where(account => account.SSN == SSN);
         return userAccounts.ToArray();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Get all the accounts for the user
 /// </summary>
 /// <param name="SSN">Social security number of the account holder</param>
 /// <returns>All the accounts of the user</returns>
 public static Account[] GetAllAccountsBySSN(int SSN)
 {
     //Connects to the database
     //BankModel db = new BankModel();
     using (var db = new BankModel())
     {
         var userAccounts = db.Accounts.Where(account => account.SSN == SSN);
         return(userAccounts.ToArray());
     }
 }
Ejemplo n.º 7
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();
     }
 }
Ejemplo n.º 8
0
 //private static List<Account> accounts = new List<Account>();
 public static Account CreateAccount(string name, int ssn)
 {
     using (var db = new BankModel())
     {
         var account = new Account(name);
         account.SSN = ssn;
         //accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Ejemplo n.º 9
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;
     }
 }
Ejemplo n.º 10
0
 public static Account CreateAccount(string name, int ssn, decimal amount, AccountType accountType, string emailAddress)
 {
     //var account = CreateAccount(name);
     //account.Deposit(amount);
     using (var db = new BankModel())
     {
         var account = new Account(name, amount);
         account.SSN = ssn;
         account.TypeOfAccount = accountType;
         account.EmailAddress = emailAddress;
         //accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a bank account
 /// </summary>
 /// <param name="name">Name of the account holder</param>
 /// <param name="ssn">ssn</param>
 /// <param name="balance">initial balance to be deposited</param>
 /// <returns>Account number</returns>
 public static Account CreateAccount(string name, int ssn, double balance)
 {
     using (var db = new BankModel())
     {
         Account account = new Account(name);
         account.SSN = ssn;
         account.AccountType = TypeOfAccount.Checking;
         if (balance > 0)
         {
             account.Deposit(balance);
         }
         accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a bank account
 /// </summary>
 /// <param name="name">Name of the account holder</param>
 /// <param name="ssn">ssn</param>
 /// <param name="balance">initial balance to be deposited</param>
 /// <returns>Account number</returns>
 public static Account CreateAccount(string name, int ssn, double balance)
 {
     using (var db = new BankModel())
     {
         Account account = new Account(name);
         account.SSN         = ssn;
         account.AccountType = TypeOfAccount.Checking;
         if (balance > 0)
         {
             account.Deposit(balance);
         }
         accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return(account);
     }
 }
Ejemplo n.º 13
0
 public static IEnumerable<Account> GetAllAccountsByEmail(string email)
 {
     var db = new BankModel();
     return db.Accounts.Where(a => a.EmailAddress.ToLower() == email.ToLower());
 }
Ejemplo n.º 14
0
 public static Account GetAccountByAccountNumber(int id)
 {
     var db = new BankModel();
     return db.Accounts.Where(a => a.AccountNumber == id).FirstOrDefault();
 }
Ejemplo n.º 15
0
 private static bool CreateTransaction(DateTime transactionDate, 
     string description, decimal amount, int accountnumber, 
     TransactionType transactionType)
 {
     try
     {
         using (var db = new BankModel())
         {
             var transaction =
                 new Transaction
                 {
                     AccountNumber = accountnumber,
                     TransactionDate = transactionDate,
                     Description = description,
                     Debit = (transactionType == TransactionType.Debit)
                                     ? amount : 0.0M,
                     Credit = (transactionType == TransactionType.Credit)
                                     ? amount : 0.0M
                 };
             db.Transactions.Add(transaction);
             db.SaveChanges();
             return true;
         }
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 16
0
 public static Account[] GetAllAccountsByEmail(string email)
 {
     //Connects to the database
     //BankModel db = new BankModel();
     using (var db = new BankModel())
     {
         var userAccounts = db.Accounts.Where(account => account.Email == email);
         return userAccounts.ToArray();
     }
 }