using FluentScheduler; using Sevomin.Models.Repositories; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sevomin.Models.Helpers.ScheduledTasks { public class ExpiringJob : ITask { public async void Execute() { var expiringJobs = JobRepository.Current.ListAll().ToList().Where(j => j.ExpireDate.Date == DateTime.UtcNow.AddDays(-2).Date); foreach (var job in expiringJobs) { SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.ExpiringJob}; emailer.Parameters.Add("", ""); await emailer.SendAsync(string.IsNullOrWhiteSpace(job.ContactPersonEMail) ? job.Avalin.Email : job.ContactPersonEMail, true, false); } } } }