/// <summary> /// triggered when transfer funds is clicked. /// creates a new form that asks for details of transfer. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TransferFundsToolStripMenuItem_Click(object sender, EventArgs e) { TransferFundsForm transferFunds = new TransferFundsForm(this.selectedUser); transferFunds.ShowDialog(); if (transferFunds.TransferAmount != 0) { User user = this.bankingApplication.GetUser(transferFunds.ToUser); if (user.CheckAccountTypeExists(transferFunds.ToAccountType)) { IAccountEntity entity = this.selectedUser.CheckStatus(transferFunds.FromAccountType) as IAccountEntity; if (entity.GetCurrentAmount() > transferFunds.TransferAmount) { this.bankingApplication.TransferFundsBetweenAccounts(this.userName, transferFunds.ToUser, transferFunds.FromAccountType, transferFunds.ToAccountType, transferFunds.TransferAmount); } else { MessageBox.Show("You don't have enough funds."); } } else { MessageBox.Show("Recipient does not have that type of account. Try Again."); } } }
public void TransferAmount() { User fromUser = this.bankUsers[this.fromUser]; User toUser = this.bankUsers[this.toUser]; IAccountEntity toAccount = toUser.CheckStatus(this.toAccountType) as IAccountEntity; IAccountEntity fromAccount = fromUser.CheckStatus(this.fromAccountType) as IAccountEntity; toAccount.SetCurrentAmount(toAccount.GetCurrentAmount() + this.transferAmount); fromAccount.SetCurrentAmount(fromAccount.GetCurrentAmount() - this.transferAmount); // create operations on both accounts for transfer.// OperationBuilder operationBuilder = new OperationBuilder() .SetType("TransferOperation") .SetAmount(this.transferAmount) .SetPayee(this.toUser); fromAccount.PushOperation(operationBuilder.Build()); operationBuilder = new OperationBuilder() .SetType("DepositOperation") .SetAmount(this.transferAmount) .SetPayee(this.fromUser); toAccount.PushOperation(operationBuilder.Build()); }
/// <summary> /// Adds an account to the set in the context. /// </summary> /// <param name="entity">The account to add.</param> public void Add(IAccountEntity entity) { if (!(entity is AccountEntity accountEntity)) { throw new ArgumentException($"The {nameof(entity)} must be of type {nameof(AccountEntity)}.", nameof(entity)); } base.Add((AccountEntity)entity); }
public AccountModel(IAccountEntity entity) { if (entity != null) { AccountId = entity.AccountId; Name = entity.Name; UserId = entity.UserId; RiskPerMonth = entity.RiskPerMonth; RiskPerTrade = entity.RiskPerTrade; } }
/// <summary> /// Shows selected account details on mainform textboxes. /// </summary> /// <param name="entity"></param> private void ShowAccountDetails(IEntity entity) { if (entity is IAccountEntity) { IAccountEntity accountEntity = entity as IAccountEntity; this.accountNumberBox.Text = accountEntity.GetEntityNumber().ToString(); this.currentBalanceBox.Text = accountEntity.GetCurrentAmount().ToString(); } if (entity is IInterestEntity) { IInterestEntity interestEntity = entity as IInterestEntity; this.interestRateBox.Text = interestEntity.GetInterestRate().ToString(); this.totalInterestAmountBox.Text = interestEntity.GetInterestValue().ToString(); } if (entity is ILoanEntity) { LoanAccount loanEntity = entity as LoanAccount; this.label7.Text = "Total Loan Amount"; this.totalAmountBox.Text = loanEntity.GetLoanAmount().ToString(); } }
/// <summary> /// Removes an entity from the set in the context. /// </summary> /// <param name="entity">The entity to remove.</param> public void Remove(IAccountEntity entity) { base.Remove((AccountEntity)entity); }
public DummyAccountRepository(IAccountEntity dummyAccountEntity) { _dummyAccountEntity = dummyAccountEntity ?? throw new ArgumentNullException(nameof(dummyAccountEntity)); }