Example #1
0
        /// <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 AccountTransactionListViewModel(ITransactionAccount account, bool isBet)
 {
     this.account = account;
     this.isBet   = isBet;
     CreateTransactions();
     this.RegisterMessages();
 }
Example #3
0
        /// <summary>
        /// Create loan account
        /// </summary>
        /// <returns></returns>
        private ILoanAccount createLoanAccount()
        {
            int        period          = Convert.ToInt32(txtPeriod.Text);
            int        unitNumPeriod   = Convert.ToInt32(txtUnitPeriod.Text);
            decimal    percent         = Convert.ToDecimal(txtPercent.Text);
            int        unitNumInterest = Convert.ToInt32(txtUnitInterestRate.Text);
            UnitOfTime unit;

            switch (unitNumPeriod)
            {
            case 0: unit = UnitOfTime.Day;
                break;

            case 1: unit = UnitOfTime.Mounth;
                break;

            case 2: unit = UnitOfTime.Year;
                break;

            default: unit = UnitOfTime.Day;
                break;
            }

            TimePeriod tp = new TimePeriod();

            tp.Period = period;
            tp.Unit   = unit;

            switch (unitNumInterest)
            {
            case 0: unit = UnitOfTime.Day;
                break;

            case 1: unit = UnitOfTime.Mounth;
                break;

            case 2: unit = UnitOfTime.Year;
                break;

            default: unit = UnitOfTime.Day;
                break;
            }

            InterestRate ir = new InterestRate();

            ir.Percent = percent;
            ir.Unit    = unit;

            DateTime start = dtpStart.Value;
            DateTime end   = dtpEnd.Value;

            ITransactionAccount ta = createTransactionAccount();

            ILoanAccount loanAccount = new LoanAccount(ta.Currency, tp, ir, start, end, ta as TransactionAccount);

            return(loanAccount);
        }
Example #4
0
 /// <summary>
 /// Populate transaction account details
 /// </summary>
 /// <param name="account"></param>
 private void populateTransactionAccount(ITransactionAccount account)
 {
     lbl_fromId.Text            = account.Id.ToString();
     lbl_fromNumber.Text        = account.Number;
     lbl_fromCurrency.Text      = account.Currency;
     lbl_fromBalance.Text       = account.Balance.Amount.ToString() + " " + account.Balance.Currency.ToString();
     lbl_fromLimitAmount.Text   = account.Limit.Amount.ToString();
     lbl_fromLimitCurrency.Text = account.Limit.Currency;
 }
Example #5
0
 /// <summary>
 /// DepositAccount constructor
 /// </summary>
 /// <param name="currency">currency of account</param>
 /// <param name="depositPeriod">deposit period</param>
 /// <param name="interestRate">interest rate</param>
 /// <param name="startDate">start date</param>
 /// <param name="endDate">end date</param>
 /// <param name="transactionAccount">tansaction account</param>
 public DepositAccount(string currency, TimePeriod depositPeriod, InterestRate interestRate,
                       DateTime startDate, DateTime endDate, TransactionAccount transactionAccount)
     : base(currency)
 {
     this.Period             = depositPeriod;
     this.Interest           = interestRate;
     this.StartDate          = startDate;
     this.EndDate            = endDate;
     this.TransactionAccount = transactionAccount;
 }
Example #6
0
        /// <summary>
        /// Button 'Make Transaction' click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMakeTransaction_Click(object sender, EventArgs e)
        {
            ITransactionAccount transactionAccount = createTransactionAccount();
            //IDepositAccount depositAccount = createDepositAccount();
            ILoanAccount loanAccount = createLoanAccount();

            ITransactionProcessor transactionProccesor = TransactionProcessor.GetTransactionProcessor();

            CurrencyAmount currencyAmount = new CurrencyAmount();

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

            //ovde dodavam event handler-i za event-ite
            transactionAccount.OnBalanceChanged += new BalanceChanged(OnBalanceChangeEventHandler);
            loanAccount.OnBalanceChanged        += new BalanceChanged(OnBalanceChangeEventHandler);

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

            try
            {
                status = transactionProccesor.ProcessTransaction(TransactionType.Credit, currencyAmount, transactionAccount, loanAccount);
            }
            catch (ApplicationException ae)
            {
                errorOccurred = true;
                errorMsg      = ae.Message;
            }
            finally
            {
                if (errorOccurred)
                {
                    MessageBox.Show(errorMsg);
                }
            }


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

            //populateDepositAccount(depositAccount);
            //populateLoanAccount(loanAccount);
            //populateTransactionAccount(transactionAccount);
            //lblNumberTransactions.Text ="Number of transactions: " + transactionProccesor.TransactionCount;
            DisplayLastTransactionDetails();
        }
Example #7
0
        /// <summary>
        /// check for transaction account
        /// </summary>
        /// <param name="account"></param>
        private void checkForTransactionAccount(IAccount account)
        {
            if (account is ITransactionAccount)
            {
                ITransactionAccount ta = account as TransactionAccount;

                lblLimitAmount.Text   = ta.Limit.Amount.ToString();
                lblLimitCurrency.Text = ta.Limit.Currency;
            }
            else
            {
                lblLimitAmount.Text   = "";
                lblLimitCurrency.Text = "";
            }
        }
Example #8
0
 public AccountAddedMessage(ITransactionAccount account)
 {
     Account = account;
 }
Example #9
0
 public void SetAccount(ITransactionAccount account)
 {
     this.action.Source = account;
 }
 public AccountNameChangedMessage(ITransactionAccount account)
 {
     Account = account;
 }
 public WalletButtonsViewModel(ITransactionAccount account, IRepository repository)
 {
     this.account    = account;
     this.repository = repository;
 }
 public void SetAccount(ITransactionAccount account)
 {
     this.action.Destination = account;
 }
Example #13
0
        /// <summary>
        /// Button 'Create Transaction Account' click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateTransactionAccount_Click(object sender, EventArgs e)
        {
            ITransactionAccount TranAccount = createTransactionAccount();

            populateAccountCommonProperties(TranAccount);
        }