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

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);
}
}
}
}
}