|
|
- using System;
- using System.Linq;
- using FluentScheduler;
- using Sevomin.Models.Repositories;
-
- namespace Sevomin.Models.Helpers.ScheduledTasks
- {
- public class NewJob : ITask
- {
- public async void Execute()
- {
- var newJobs = JobRepository.Current.ListAll().ToList().Where(j => j.CreateDate.Date >= DateTime.UtcNow.AddDays(-1).Date).ToList();
- if (newJobs.Count > 0)
- {
- foreach (var dovomin in UserRepository.Current.ListAll().Where(u => u is Dovomin && u.EmailConfirmed))
- {
- SevominEmailer emailer = new SevominEmailer();
- emailer.EmailType = EmailType.NewJob;
- emailer.Parameters.Add("display-name", dovomin.DisplayName);
-
- await emailer.SendAsync(dovomin.Email, true, ((Dovomin) dovomin).OptOutEmail);
- }
- }
- }
- }
- }
|