public void CheckWorkers() { var workers = context.Worker.Include(x => x.Company); var now = DateTime.Now; var fiveMinutesBefore = now.AddMinutes(-5); var dateString = $"{now.ToLongDateString()}, {now.ToShortTimeString()} -"; var updatedWorkers = workers.Where(x => x.TimeUpdated > fiveMinutesBefore && x.TimeUpdated <= now); if (updatedWorkers.Any()) { logger.LogInformation($"{dateString} {updatedWorkers.Count()} workers were updated"); sendEmail.SendBasicEmail(updatedWorkers); } else { logger.LogInformation($"{dateString} No workers were updated"); } }