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.

29 lines
1.0 KiB

11 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 NewJob : ITask
  11. {
  12. public async void Execute()
  13. {
  14. var newJobs = JobRepository.Current.ListAll().ToList().Where(j => j.CreateDate.Date >= DateTime.UtcNow.AddDays(-1).Date).ToList();
  15. if (newJobs.Count > 0)
  16. {
  17. foreach (var dovomin in UserRepository.Current.ListAll().Where(u => u is Dovomin && u.EmailConfirmed))
  18. {
  19. SevominEmailer emailer = new SevominEmailer();
  20. emailer.EmailType = EmailType.NewJob;
  21. emailer.Parameters.Add("display-name", dovomin.DisplayName);
  22. await emailer.SendAsync(dovomin.Email, "آگهی استخدام جدید در سومین", true);
  23. }
  24. }
  25. }
  26. }
  27. }