// Display all transactions of Account public void ViewTransactionsofCustomer() { IList <Models.Transaction.Transaction> transactions; string customerID; string accountID; int index = 0; customerID = DisplayAndSelectCustomerID(); if (customerID == String.Empty || customerID == null) { return; } accountID = DisplayAndSelectAccountOfCustomer(customerID); if (accountID == String.Empty || accountID == null) { return; } transactions = _transactionService.GetTransactionsByAccountID(accountID); _UIBuffer.WriteLine("\n-------------------------------------------------------------------------------------------------------------------------------"); _UIBuffer.WriteLine(String.Format(" {0,-5} {1,-40} {2,-40} {3,-40} {4,-7} {5,-7}", "S.NO", "Transaction ID", "Payor", "Payee", "Amount", "Type")); foreach (Models.Transaction.Transaction transaction in transactions) { _UIBuffer.WriteLine(String.Format(" {0,-5} {1,-40} {2,-40} {3,-40} {4,-7} {5,-7}", index, transaction.ID, (transaction.PayeeID ?? "------------------------------------"), (transaction.PayorID ?? "-------------------------------------" + " "), transaction.Amount, transaction.Type)); index++; } _UIBuffer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------\n"); _UIBuffer.ReadKey(); }
// Display history of an account. private void ViewHistoryofAccount() { IList <Models.Transaction.Transaction> transactionsList; int index = 1; bool IsCreditingTransaction; _UIBuffer.WriteLine(" select the accountr\n"); _selectedAccountID = DisplayAndSelectAccountOfUser(); if (_selectedAccountID == null) { return; } transactionsList = _transactionService.GetTransactionsByAccountID(_selectedAccountID); _UIBuffer.WriteLine("--------------------------------------------------------------------------------\n"); _UIBuffer.WriteLine(string.Format(" {0,-7} {1,-8} {2,-40} {3,-8} {4,-8}", "S.NO", "Date", "Transaction ID", "Amount", "Type")); foreach (Models.Transaction.Transaction transaction in transactionsList) { // Determining wheather transaction is Credit or Debit if (transaction.Type == Models.Transaction.TransactionType.Transfer) { if (transaction.PayeeID == _selectedAccountID) { IsCreditingTransaction = true; } else { IsCreditingTransaction = false; } } else { if (transaction.Type == Models.Transaction.TransactionType.Deposit) { IsCreditingTransaction = true; } else { IsCreditingTransaction = false; } } if (IsCreditingTransaction) { _UIBuffer.Write(String.Format(" {0,-5} {1,-8} {2,-40} {3,-8}", index, transaction.CreatedOn.ToString("dd/MM/yyyy"), transaction.ID, transaction.Amount)); _UIBuffer.Write(String.Format("{0,-8}", "Credit\n")); } else { _UIBuffer.Write(String.Format(" {0,-5} {1,-8} {2,-40} {3,-8}", index, transaction.CreatedOn.ToString("dd/MM/yyyy"), transaction.ID, transaction.Amount)); _UIBuffer.Write(String.Format("{0,-8}", "debit\n")); } index++; } _UIBuffer.WriteLine("--------------------------------------------------------------------------------\n"); }