public static void AccountCloser(string accId) { TransactionStore.AddCloseTransaction(accId); AccountStore.StoredAccounts.Remove(accId); AccountBalance.Balance.Remove(accId); Console.WriteLine("Account " + accId + " has been closed!"); }
public static void AccountCloser() { AccViewer.getAccounts(); while (true) { Console.WriteLine("Please enter the account Id you wish to close..."); AccId = Console.ReadLine(); if (AccountStore.StoredAccounts.ContainsKey(AccId)) { break; } else { Parsers.InvalidInput(); } } if (AccountBalance.Balance[AccId] != 0 || !(AccountStore.StoredAccounts[AccId]._AssociatedAccountId is null)) { Console.WriteLine("You cannot close an account with an outstanding balance!\nAccount " + AccId + " has a balance of $" + AccountBalance.Balance[AccId]); if (!(AccountStore.StoredAccounts[AccId]._AssociatedAccountId is null)) { Console.WriteLine("and the associated account " + AccountStore.StoredAccounts[AccId]._AssociatedAccountId + " has a balance of $" + AccountBalance.Balance[AccountStore.StoredAccounts[AccId]._AssociatedAccountId]); } } else { TransactionStore.AddCloseTransaction(AccId); AccountStore.StoredAccounts.Remove(AccId); AccountBalance.Balance.Remove(AccId); Console.WriteLine("Account " + AccId + " has been closed!"); } }