public void StoreTransaction(long accountNo, double Amount, TypeOfTranscation type, string mode, string chequeNo) { //// retrieving customerID based on account No string customerID = "00000000000000";// dummy initialization to avoid warnings foreach (Account acc in AccountDAL.ListOfAccounts) { if (acc.AccountNo == accountNo) { customerID = acc.CustomerID; } } DateTime time = DateTime.Now; string transactionID = "TRANS" + time.ToString("yyyyMMddhhmmss");//sample transactionID : TRANS20190921154525 TransactionEntities trans = new TransactionEntities(); trans.AccountNo = accountNo; trans.CustomerID = customerID; trans.Type = type; trans.Amount = Amount; trans.TransactionID = transactionID; trans.DateOfTransaction = time; trans.Mode = mode; trans.ChequeNo = chequeNo; Transactions.Add(trans); }
/// <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."); } }
public abstract bool StoreTransactionRecord(Guid accountID, double Amount, TypeOfTranscation type, ModeOfTransaction mode, string chequeNo);
public abstract void StoreTransaction(long accountNo, double Amount, TypeOfTranscation type, string mode, string chequeNo);