public async Task RegisterInPayments(string directory, DateTimeOffset date) { var fileToImport = new BankStatementFile(directory, date); if (!fileToImport.Exists()) { return; } using (dataStore) { foreach (var txLine in fileToImport.Read()) { var account = await dataStore.PolicyAccounts.FindByNumber(txLine.AccountNumber); account?.InPayment(txLine.Amount, txLine.AccountingDate); dataStore.PolicyAccounts.Update(account); } fileToImport.MarkProcessed(); await dataStore.CommitChanges(); } }
public void RegisterInPayments(string directory, DateTimeOffset date) { var fileToImport = new BankStatementFile(directory, date); if (!fileToImport.Exists()) { return; } using (uow) { fileToImport .Read() .ForEach(bs => uow.PolicyAccounts.FindByNumber(bs.AccountNumber)?.InPayment(bs.Amount, bs.AccountingDate)); fileToImport.MarkProcessed(); uow.CommitChanges(); } }