public IActionResult DoPersistence(StringDictionary arguments) { io.Info.Write("Starting new persistence run."); var lastStoredTransaction = transactionRepository.GetLastTransaction(); var nextDayToPersist = lastStoredTransaction.IsNoTransaction() ? new DateTime(date.Now.Year, 1, 1) : lastStoredTransaction.EntryDate.AddDays(1); DateTime yesterday = date.Now.AddDays(-1); arguments = arguments.NewCopy(); arguments.Add(Arguments.FromDate, nextDayToPersist.ToIsoDate()); io.Info.Write("Next day to persist: {0}", nextDayToPersist.ToIsoDate()); IActionResult result = finTsService.DoAction(ActionPersist.ActionName, arguments); if (result.Status != Status.Success) { return result; } var filteredTransactions = result.Response.Transactions .Where(t => t.EntryDate <= yesterday) .Select(x => x.ToTransaction()) .ToList(); if (filteredTransactions.Any()) { io.Info.Write("Found {0} new transactions to persist.", filteredTransactions.Count); transactionRepository.SaveTransactions(filteredTransactions); } else { io.Info.Write("Found no new transactions to persist."); } return result; }