/// <summary>
        /// User mini statement view controller
        /// Entry Criteria : userid and accountid shouldnt be null.
        /// Responsibility : Display user mini statement
        /// Success Criteria : Fetchs users transactions from DB displays to user
        /// Exception condition: Fail when the database call fails for any exception.
        /// @return
        /// @throws SQLException
        /// @throws ClassNotFoundException
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="accountId"></param>
        /// <returns>UserTransactionsModel</returns>
        public ActionResult ViewMiniStatement(int userId, int accountId)
        {
            MiniStatementFacade   _miniStatementFacade  = new MiniStatementFacade();
            UserTransactionsModel userTransactionsModel = new UserTransactionsModel();

            try
            {
                IList <UserTransactionsData> transactions = _miniStatementFacade.GetUserTransactionsByAccountId(userId, accountId);
                if (transactions.Count > 0)
                {
                    userTransactionsModel.AccountType   = _miniStatementFacade.GetAccountTypeByAccountId(transactions.FirstOrDefault().AccountId);
                    userTransactionsModel.AccountNumber = transactions.FirstOrDefault().AccountNumber;
                }
                userTransactionsModel.UserTransactions = transactions;
                ViewBag.accountBalance = GetAccountBalance(transactions);
            }
            catch (Exception)
            {
            }
            return(View(userTransactionsModel));
        }
Beispiel #2
0
        private void PrepareModel(UserTransactionsModel model, int userId, int accountId)
        {
            try
            {
                MiniStatementFacade _miniStatementFacade = new MiniStatementFacade();
                IList <Transaction> transactions         = _miniStatementFacade.GetUserTransactionsByAccountId(userId, accountId);
                var userAccounts = _miniStatementFacade.GeUsertAccountsByUserId(userId);
                var userAccount  = userAccounts.Where(x => x.AccountId == accountId).FirstOrDefault();

                if (transactions.Count > 0)
                {
                    var account = transactions[0].Account;
                    model.AccountType   = account.AccountName;
                    model.AccountNumber = userAccount.AccountNumber;
                }
                model.UserTransactions = transactions;
                model.AccountBalance   = GetAccountBalance(transactions);
                model.UserId           = userId;
                model.AccountId        = accountId;
            }
            catch (Exception)
            {
            }
        }