Example #1
0
        /// <summary>
        /// Extension Method for charging fee
        /// </summary>
        /// <param name="processor">transaction processor</param>
        /// <param name="amount">amount</param>
        /// <param name="accounts">array of account</param>
        /// <returns>transaction status</returns>
        public static TransactionStatus ChargeProcessingFee(this ITransactionProcessor processor, CurrencyAmount amount, IEnumerable <IAccount> accounts)
        {
            TransactionStatus result = TransactionStatus.Failed;

            result = processor.ProcessGroupTransaction(TransactionType.Debit, amount, accounts.ToArray());

            return(result);
        }
Example #2
0
        /// <summary>
        /// Button 'Make Group Transaction' click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMakeGroupTransaction_Click(object sender, EventArgs e)
        {
            IAccount[] acounts = new IAccount[2];

            //IDepositAccount depositAccount = createDepositAccount();
            //ILoanAccount loanAccount = createLoanAccount();

            //acounts[0] = depositAccount;
            //acounts[1] = loanAccount;

            Dictionary <CreateAccountType, IAccount> accountsDictionary = CreateAccounts(CreateAccountType.DepositAccount | CreateAccountType.LoanAccount, null);

            acounts[0] = accountsDictionary[CreateAccountType.DepositAccount];
            acounts[1] = accountsDictionary[CreateAccountType.LoanAccount];

            ITransactionProcessor transactionProccesor = TransactionProcessor.GetTransactionProcessor();

            CurrencyAmount currencyAmount = new CurrencyAmount();

            currencyAmount.Amount   = Convert.ToInt32(txtTransactionAmoun.Text);
            currencyAmount.Currency = txtTransactionCurrency.Text;


            bool              errorOccurred = false;
            string            errorMsg      = "";
            TransactionStatus status        = TransactionStatus.Failed;

            try
            {
                status = transactionProccesor.ProcessGroupTransaction(TransactionType.Debit, currencyAmount, acounts);
            }
            catch (CurrencyMismatchException cme)
            {
                errorOccurred = true;
                errorMsg      = cme.Message;
            }
            catch (ApplicationException)
            {
                throw;
            }
            finally
            {
                if (errorOccurred)
                {
                    MessageBox.Show(errorMsg);
                }
            }



            if (status.Equals(TransactionStatus.Completed))
            {
                lblTransactionStatus.Text = "Transaction Completed";
            }
            else
            {
                lblTransactionStatus.Text = "Transaction Failed";
            }

            //populateDepositAccount(depositAccount);
            //populateLoanAccount(loanAccount);
            //lblNumberTransactions.Text ="Number of transactions: " + transactionProccesor.TransactionCount;
            DisplayLastTransactionDetails();
        }