public void SaveAccount(List <Account> accounts) { using (StreamWriter streamWriter = new StreamWriter("Accounts.txt")) { streamWriter.WriteLine("AccountNumber,Name,Balance,Type"); foreach (var item in accounts) { streamWriter.WriteLine(AccountMappers.ToStringCSV(item)); } } }
public List <Account> RetrieveAccounts() { List <Account> results = new List <Account>(); using (StreamReader streamReader = new StreamReader("Accounts.txt")) { string row = streamReader.ReadLine(); while ((row = streamReader.ReadLine()) != null) { Account accounts = AccountMappers.ToAccount(row); results.Add(accounts); } } return(results); }