/// <summary> /// Save collection of bank accounts to storage. /// </summary> /// <param name="storage">Storage to save.</param> public void SaveToStorage(IBankAccountStorage storage) { if (ReferenceEquals(storage, null)) { throw new ArgumentException($"{nameof(storage)} is null."); } storage.WriteToStorage(bankAccountList); }
/// <summary> /// Load collection of bank accounts from storage. /// </summary> /// <param name="storage">Storage to load.</param> public void LoadFromStorage(IBankAccountStorage storage) { if (ReferenceEquals(storage, null)) { throw new ArgumentException($"{nameof(storage)} is null."); } IEnumerable <BankAccount> bookList = storage.ReadFromStorage(); foreach (BankAccount bankAccount in bankAccountList) { this.AddBankAccount(bankAccount); } }
/// <summary> /// Initializes a new instance of the <see cref="BankAccountService"/> class by instance of factory of storage. /// </summary> /// <param name="bankAccountStorage">The storage.</param> /// <param name="bankAccountFactory">The factory of bank accounts.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="bankAccountStorage"/> is null. /// <paramref name="bankAccountFactory"/> is null. /// </exception> public BankAccountService(IBankAccountStorage bankAccountStorage, BankAccountMapper bankAccountMapper) { if (bankAccountStorage is null) { throw new ArgumentNullException(nameof(bankAccountStorage)); } if (bankAccountMapper is null) { throw new ArgumentNullException(nameof(bankAccountMapper)); } this.bankAccountStorage = bankAccountStorage; this.bankAccountMapper = bankAccountMapper; this.listBankAccounts = this.bankAccountStorage.Load().Select(m => this.bankAccountMapper.ToBankAccount(m)).ToList(); }
/// <summary> /// Constructor for class BankAccountService /// </summary> /// <param name="storage">storage for bank account</param> public BankAccountService(IBankAccountStorage storage) { this.storage = storage; }