/// <summary> /// Create Bank Account /// </summary> /// <param name="accounttype">enum AccountType</param> /// <param name="amount">double amount</param> /// <returns>returns the account number</returns> public Guid CreateBankAccount(string personName, AccountType accounttype, decimal amount = 0) { var personId = CreateOrReturnPerson(personName); Account a; var id = Guid.NewGuid().ToString(); switch (accounttype) { case AccountType.CheckingsAcccount: InsertOrUpdate.CheckingsAccount(personId, amount); var checkings = Get.CheckingsAccount(personId); a = new CheckingsAccount(checkings.AccountId, checkings.Amount); _accounts.Add(a); return(a.AccountNumber); case AccountType.SavingsAccount: InsertOrUpdate.SavingsAccount(personId, amount); var savings = Get.SavingsAccount(personId); a = new SavingsAccount(savings.AccountId, savings.Amount, savings.Interest); _accounts.Add(a); return(a.AccountNumber); default: return(Guid.Empty); } }
/// <summary> /// Create Bank Account /// </summary> /// <param name="accounttype">enum AccountType</param> /// <param name="amount">double amount</param> /// <returns>returns the account number</returns> public string CreateBankAccount(AccountType accounttype, double amount) { Account a; var id = Guid.NewGuid().ToString(); switch (accounttype) { case AccountType.CheckingsAcccount: a = new CheckingsAccount(id, amount); _accounts.Add(a); return(a.AccountNumber); case AccountType.SavingsAccount: a = new SavingsAccount(id, amount, _intrestRate); _accounts.Add(a); return(a.AccountNumber); case AccountType.LosingsAccount: a = new LosingsAccount(id, amount, _intrestRate); _accounts.Add(a); return(a.AccountNumber); default: return(string.Empty); } }
static void Main(string[] args) { GeneralAccountcs JohnAccount = new GeneralAccountcs(0); SavingsAccount savingsAccount = new SavingsAccount(50000); JohnSavingAccount.Setinterest(0.75); ChekingsAccount chekingsAccount = new CheckingsAccount(20000); JohnCheckingAccount.setinterest(14.50); }
public static Guid CheckingsAccount(int personId, decimal amount) { using (var db = new BankingSystemEntities()) { var account = new CheckingsAccount { PersonId = personId, AccountId = Guid.NewGuid(), Amount = amount }; db.CheckingsAccounts.Add(account); db.SaveChanges(); return(account.AccountId); } }
public Customer(String name) { _name = name; _checkingsAccount = new CheckingsAccount(); _savingsAccount = new SavingsAccount(); }
public void WithdrawCheckings(decimal amount) { CheckingsAccount.Withdraw(amount); }
public void DepositCheckings(decimal amount) { CheckingsAccount.Deposit(amount); }
public decimal CheckingsWithdraw(decimal deposit) { CheckingsAccount.Withdraw(deposit); return(CheckingsAccount.Balance); }
public decimal CheckingsDeposit(decimal deposit) { CheckingsAccount.Deposit(deposit); return(CheckingsAccount.Balance); }
public static void Main(string[] args) { var account = new BankAccount(); Console.WriteLine("Testing not enough digits:"); account.AccountNumber = "1234"; Console.WriteLine(" "); Console.WriteLine("Testing too many digits:"); account.AccountNumber = "1234567"; Console.WriteLine(" "); Console.WriteLine("Testing 6 digits:"); account.AccountNumber = "123456"; Console.WriteLine(account.AccountNumber); Console.WriteLine(" "); Console.WriteLine("Test account name:"); account.Name = "Michael"; Console.WriteLine(account.Name); Console.WriteLine(" "); Console.WriteLine("Test negative balance fail:"); account.Balance = -1; Console.WriteLine(" "); Console.WriteLine("Test: display positive balance:"); account.Balance = 2; Console.WriteLine(account.Balance); Console.WriteLine(" "); Console.WriteLine("Test future date fail:"); account.DateCreated = new DateTime(2021, 1, 1, 0, 0, 0); Console.WriteLine(" "); Console.WriteLine("Test past date success:"); account.DateCreated = new DateTime(2019, 1, 1, 0, 0, 0); Console.WriteLine(account.DateCreated); Console.WriteLine(" "); Console.WriteLine("Constructor noargs DateCreated:"); var accountNoArgs = new BankAccount(); Console.WriteLine(accountNoArgs.DateCreated); Console.WriteLine(" "); Console.WriteLine("Constructor 3args:"); var account3Args = new BankAccount("123456", "Mark", 37.50m); Console.WriteLine(account3Args.AccountNumber); Console.WriteLine(account3Args.Name); Console.WriteLine(account3Args.Balance); Console.WriteLine(account3Args.DateCreated); Console.WriteLine(" "); Console.WriteLine("DisplayAccountInfo test:"); var displayAccountInfo = new BankAccount("123123", "Mastercard", 10.21m); displayAccountInfo.DisplayAccountInfo(); Console.WriteLine(" "); Console.WriteLine("Test Deposit:"); var depositTest = new BankAccount(); depositTest.Deposit(10.42m); Console.WriteLine(" "); Console.WriteLine("Test low balance fail:"); var notEnoughMoney = new BankAccount(); notEnoughMoney.Withdraw(10m); Console.WriteLine(" "); Console.WriteLine("Test fund withdrawal:"); var withdrawEnoughMoney = new BankAccount("666666", "Jeff", 20m); Console.WriteLine("Your balance is " + withdrawEnoughMoney.Balance); withdrawEnoughMoney.Withdraw(10m); Console.WriteLine(" "); Console.WriteLine("Test interest calculator:"); var calculateInterest = new BankAccount(); calculateInterest.CalculateInterest(); Console.WriteLine(" "); Console.WriteLine("Test can't be less than 2500:"); var myFirstSavingsAccount = new SavingsAccount(); myFirstSavingsAccount.Balance = 0m; Console.WriteLine(myFirstSavingsAccount.Balance); Console.WriteLine(" "); Console.WriteLine("Test savings account no arg:"); var savingsAccount3args = new SavingsAccount("098763", "Paul", 2560m); Console.WriteLine(savingsAccount3args.AccountNumber); Console.WriteLine(savingsAccount3args.Name); Console.WriteLine(savingsAccount3args.Balance); Console.WriteLine(savingsAccount3args.DateCreated); Console.WriteLine(" "); Console.WriteLine("Test savings account 3 arg"); var savingsAccountInterest = new SavingsAccount("098763", "Paul", 3000m); Console.WriteLine(savingsAccountInterest.AccountNumber); Console.WriteLine(savingsAccountInterest.Name); Console.WriteLine(savingsAccountInterest.Balance); Console.WriteLine(savingsAccountInterest.DateCreated); Console.WriteLine(" "); Console.WriteLine("Test savings account interest calculator"); savingsAccountInterest.CalculateInterest(); Console.WriteLine(""); Console.WriteLine("Test savings account withdraw"); savingsAccountInterest.Withdraw(20m); Console.WriteLine(""); Console.WriteLine("Test savings account balance under 2500"); savingsAccountInterest.Withdraw(4000m); Console.WriteLine(""); Console.WriteLine("Test checking account no arg"); var myFirstCheckingsAccount = new CheckingsAccount(); myFirstCheckingsAccount.Balance = 0m; Console.WriteLine(myFirstCheckingsAccount.Balance); Console.WriteLine(" "); Console.WriteLine("Test checkings account 3 arg:"); var checkingsAccount3args = new CheckingsAccount("583094", "Bob", 3200m); Console.WriteLine(checkingsAccount3args.AccountNumber); Console.WriteLine(checkingsAccount3args.Name); Console.WriteLine(checkingsAccount3args.Balance); Console.WriteLine(checkingsAccount3args.DateCreated); Console.WriteLine(" "); Console.WriteLine("Testing check account added interest"); checkingsAccount3args.CalculateInterest(); Console.WriteLine(" "); Console.WriteLine("Testing checking account funds under 500 threshold"); checkingsAccount3args.Withdraw(5000m); }