You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
866 B

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. using FluentScheduler;
  2. using Sevomin.Models.Repositories;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Sevomin.Models.Helpers.ScheduledTasks
  9. {
  10. public class ExpiringJob : ITask
  11. {
  12. public async void Execute()
  13. {
  14. var expiringJobs = JobRepository.Current.ListAll().ToList().Where(j => j.ExpireDate.Date == DateTime.UtcNow.AddDays(-2).Date);
  15. foreach (var job in expiringJobs)
  16. {
  17. SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.ExpiringJob};
  18. emailer.Parameters.Add("", "");
  19. await emailer.SendAsync(string.IsNullOrWhiteSpace(job.ContactPersonEMail) ? job.Avalin.Email : job.ContactPersonEMail, true, false);
  20. }
  21. }
  22. }
  23. }