private static async Task DeactivateChallenges(ServiceProvider services) { var dbContext = services.GetRequiredService <SportClubsChallengesDbContext>(); var job = new DeactivateChallengesJob(dbContext); await job.Run(); }
public async Task RunAsync( [TimerTrigger("0 0 2 * * *")] TimerInfo myTimer, ILogger log) { log.LogInformation($"Timer trigger function {nameof(UpdateChallenges)} executed at: {DateTime.Now}"); var activeChallenges = await this.db.Challenges.Where(p => p.IsActive).ToListAsync(); foreach (var challenge in activeChallenges) { log.LogDebug($"Update classification of '{challenge.Name}' challenge"); var job = new UpdateChallengesClassificationsJob(this.db); await job.Run(challenge.Id); } log.LogDebug($"Deactivate past challenges"); var deactivateJob = new DeactivateChallengesJob(this.db); await deactivateJob.Run(); }