public void RemoveAccount(AccountDal account) { var accounts = new List <AccountDal>(GetBankAccounts()); accounts.Remove(FindAccount(account, accounts)); SetBankAccounts(accounts); }
public void AddAccount(AccountDal account) { using (FileStream fs = File.Open(_filePath, FileMode.Append)) using (BinaryWriter writer = new BinaryWriter(fs)) { WriteAccount(account, writer); } }
private void WriteAccount(AccountDal account, BinaryWriter writer) { writer.Write(account.Number); writer.Write((int)account.Type); writer.Write(account.FirstName); writer.Write(account.LastName); writer.Write(account.Balance); writer.Write(account.Bonus); }
private AccountDal FindAccount(AccountDal account, IEnumerable <AccountDal> accounts) { AccountDal resultAccount = null; foreach (var acc in accounts) { if (acc.Number == account.Number) { resultAccount = acc; } } if (ReferenceEquals(resultAccount, null)) { throw new AccountNotFoundException("An error occurred while searching for an account."); } return(resultAccount); }