Start Job Cleanup Service
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using BoredCareers.Entities;
|
||||
|
||||
namespace BoredCareers.Services.TimerService {
|
||||
public class JobCleanupService : BackgroundService {
|
||||
|
||||
private readonly DatabaseService.DatabaseService _db;
|
||||
|
||||
public JobCleanupService(DatabaseService.DatabaseService db) {
|
||||
_db = db;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) {
|
||||
while (!stoppingToken.IsCancellationRequested) {
|
||||
try {
|
||||
JobListing[] deletedJobListings = await _db.GetJobListingsPastExipre();
|
||||
await _db.DeleteJobListingsPastExipre();
|
||||
foreach (JobListing listing in deletedJobListings) {
|
||||
// Get applicants for each closed listing
|
||||
// Notify applicants of the listing closing
|
||||
// Mark company for auto-closed job -> ghost listing
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine($"Error: {e.Message}");
|
||||
}
|
||||
await Task.Delay(TimeSpan.FromHours(24), stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user