public Transactions() { Balance = new BankBalance();// Holds balance if (FileNameMissing()) { SetFileName(); } }
public Transactions(decimal StartingBalance) { Balance = new BankBalance(StartingBalance); if (FileNameMissing()) { SetFileName(); } }
//Remove the transaction in the list at the given index and add a new transaction at the same position public void UpdateTransaction(int Index, Transaction NewTransaction) { if (IndexIsValid(Index)) { decimal NewAmount = BankBalance.CalculateTransactionAmount(NewTransaction.Amount, NewTransaction.Type); RemoveAt(Index);//This will update balance as well List.Insert(Index, NewTransaction); Balance.AdjustBalance(NewAmount, NewTransaction.Type); } else { throw new ApplicationException("Index is out of range, can't update transaction"); } }