public void NotifyUnaffiliatedVolunteers() { var volunteerUsers = _volunteerRepository.GetVolunteers(); var volunteers = _volunteerRepository.GetUnaffiliatedVolunteers(); var availableForNotificationVolunteerIds = volunteers .Where(v => v.UnaffiliationStartTime.Value.Date.AddMonths(1) < DateTime.UtcNow.Date) .Select(v => v.ID.ToString()) .ToList(); var availableForNotificationVolunteers = volunteerUsers.Where(u => availableForNotificationVolunteerIds.Contains(u.Id)); foreach (var volunteer in availableForNotificationVolunteers) { _emailSender.SendEmailAsync(volunteer.Email, "Unaffiliation notification", $"Dear {volunteer.UserName}, <br/> Your account will be deleted due to unaffiliation in 48 hours."); } }