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.

26 lines
960 B

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. using System;
  2. using System.Linq;
  3. using FluentScheduler;
  4. using Sevomin.Models.Repositories;
  5. namespace Sevomin.Models.Helpers.ScheduledTasks
  6. {
  7. public class NewJob : ITask
  8. {
  9. public async void Execute()
  10. {
  11. var newJobs = JobRepository.Current.ListAll().ToList().Where(j => j.CreateDate.Date >= DateTime.UtcNow.AddDays(-1).Date).ToList();
  12. if (newJobs.Count > 0)
  13. {
  14. foreach (var dovomin in UserRepository.Current.ListAll().Where(u => u is Dovomin && u.EmailConfirmed))
  15. {
  16. SevominEmailer emailer = new SevominEmailer();
  17. emailer.EmailType = EmailType.NewJob;
  18. emailer.Parameters.Add("display-name", dovomin.DisplayName);
  19. await emailer.SendAsync(dovomin.Email, true, ((Dovomin) dovomin).OptOutEmail);
  20. }
  21. }
  22. }
  23. }
  24. }