コード例 #1
0
        /// <summary>
        /// Stores all transaction records to Transactions collection.
        /// </summary>
        /// <param name="accountID">Uniquely generated account ID.</param>
        /// <param name="amount">Amount to be transacted.</param>
        /// <param name="type">Type of transaction such as credit, debit.</param>
        /// <param name="mode">Mode of transaction such as cheque or withdrawal slip.</param>
        /// <param name="chequeNumber">Cheque number if mode of transaction is cheque and null in case of withdrawal slip.</param>
        /// <returns>Determinates whether the transactions are stored.</returns>
        public override bool StoreTransactionRecord(Guid accountID, double amount, TypeOfTranscation type,
                                                    ModeOfTransaction mode, string chequeNumber)
        {
            try
            {
                //// retrieving customerID based on account No
                AccountDAL     accountDAL = new AccountDAL();
                List <Account> accounts   = accountDAL.DeserializeFromJSON("AccountData.txt");
                string         customerID = "00000000000000";// dummy initialization to avoid warnings
                foreach (Account account in accounts)
                {
                    if (account.AccountID == accountID)
                    {
                        customerID = account.CustomerID.ToString();
                    }
                }

                DateTime time          = DateTime.Now;
                Guid     TransactionID = Guid.NewGuid();

                Transaction transaction = new Transaction();
                transaction.AccountID         = accountID;
                transaction.Type              = type;
                transaction.Amount            = amount;
                transaction.TransactionID     = TransactionID;
                transaction.DateOfTransaction = time;
                transaction.Mode              = mode;
                transaction.ChequeNumber      = chequeNumber;

                List <Transaction> TransactionsRecords = DeserializeFromJSON(filepath);
                TransactionsRecords.Add(transaction);
                return(SerializeIntoJSON(TransactionsRecords, filepath));
            }

            catch (PecuniaException)
            {
                throw new StoreTransactionException("Transaction not stored.");
            }
        }
コード例 #2
0
 public abstract bool StoreTransactionRecord(Guid accountID, double Amount, TypeOfTranscation type, ModeOfTransaction mode, string chequeNo);