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); }
public static void CreateAccount(Account account) { using (var db = new BankModel()) { db.Accounts.Add(account); db.SaveChanges(); } }
public static Account GetAccountByAccountNumber(int accountNumber) { using (var db = new BankModel()) { var userAccount = db.Accounts.Where(account => account.AccountNumber == accountNumber).FirstOrDefault(); return userAccount; } }
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(); } }
/// <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(); } }
/// <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()); } }
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(); } }
//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; } }
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; } }
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; } }
/// <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; } }
/// <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); } }
public static IEnumerable<Account> GetAllAccountsByEmail(string email) { var db = new BankModel(); return db.Accounts.Where(a => a.EmailAddress.ToLower() == email.ToLower()); }
public static Account GetAccountByAccountNumber(int id) { var db = new BankModel(); return db.Accounts.Where(a => a.AccountNumber == id).FirstOrDefault(); }
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; } }
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(); } }