/// <summary> /// Button 'Charge Fee' click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChargeFee_Click(object sender, EventArgs e) { ITransactionProcessor transactionProccesor = TransactionProcessor.GetTransactionProcessor(); CurrencyAmount currencyAmount = new CurrencyAmount(); currencyAmount.Amount = Convert.ToInt32(txtTransactionAmoun.Text); currencyAmount.Currency = txtTransactionCurrency.Text; IDepositAccount depositAccount = createDepositAccount(); ILoanAccount loanAccount = createLoanAccount(); List <IAccount> accounts = new List <IAccount>(); accounts.Add(depositAccount); accounts.Add(loanAccount); TransactionStatus status = ProcessorExtensions.ChargeProcessingFee(transactionProccesor, currencyAmount, accounts); if (status.Equals(TransactionStatus.Completed)) { lblTransactionStatus.Text = "Transaction Completed"; } else { lblTransactionStatus.Text = "Transaction Failed"; } DisplayLastTransactionDetails(); }
/// <summary> /// Method for creating accounts /// </summary> /// <param name="accountTypesToCreate">account type</param> /// <param name="transactionAccount">transaction account</param> /// <returns>dictionary of created accounts</returns> private Dictionary <CreateAccountType, IAccount> CreateAccounts(CreateAccountType accountTypesToCreate, ITransactionAccount transactionAccount) { Dictionary <CreateAccountType, IAccount> accounts = new Dictionary <CreateAccountType, IAccount>(); if ((accountTypesToCreate & CreateAccountType.TransactionAccount) == CreateAccountType.TransactionAccount) { ITransactionAccount transactionAccountLocal = createTransactionAccount(); accounts.Add(CreateAccountType.TransactionAccount, transactionAccount); } if ((accountTypesToCreate & CreateAccountType.DepositAccount) == CreateAccountType.DepositAccount) { IDepositAccount depositAccount = createDepositAccount(); accounts.Add(CreateAccountType.DepositAccount, depositAccount); } if ((accountTypesToCreate & CreateAccountType.LoanAccount) == CreateAccountType.LoanAccount) { ILoanAccount loanAccount = createLoanAccount(); accounts.Add(CreateAccountType.LoanAccount, loanAccount); } return(accounts); }
public void Transfer(IWithdrawalAndDepositAccount from, IDepositAccount to, decimal amount) { if (from.Amount < amount) { throw new InvalidOperationException(); } from.Withdraw(amount); to.Deposit(amount); }
/// <summary> /// Populate deposit account details /// </summary> /// <param name="account"></param> private void populateDepositAccount(IDepositAccount account) { lbl_toId.Text = account.Id.ToString(); lbl_toNumber.Text = account.Number; lbl_toCurrency.Text = account.Currency; lbl_toBalance.Text = account.Balance.Amount.ToString() + " " + account.Balance.Currency.ToString(); lbl_toPeriod.Text = account.Period.Period + " " + account.Period.Unit; lbl_toInterest.Text = account.Interest.Percent + " % " + account.Interest.Unit; lbl_toStartDate.Text = account.StartDate.ToString(); lbl_toEndDate.Text = account.EndDate.ToString(); }
/// <summary> /// Check for deposit account /// </summary> /// <param name="account"></param> private void checkForDepositAccount(IAccount account) { if (account is IDepositAccount) { IDepositAccount da = account as DepositAccount; lblPeriod.Text = da.Period.Period + " " + da.Period.Unit; lblInterest.Text = da.Interest.Percent + " " + da.Interest.Unit; lblStartDate.Text = da.StartDate.ToString(); lblEndDate.Text = da.EndDate.ToString(); } else { lblPeriod.Text = ""; lblInterest.Text = ""; lblStartDate.Text = ""; lblEndDate.Text = ""; } }
public void DepositMoneyTo(IDepositAccount depositAccount, decimal amount) { depositAccount.Deposit(amount); }
/// <summary> /// Button 'Create Deposit Account' click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateDepositAccount_Click(object sender, EventArgs e) { IDepositAccount DepAccount = createDepositAccount(); populateAccountCommonProperties(DepAccount); }