Refactored event service injection

This commit is contained in:
2026-10-29 06:46:48 +02:00
parent 04b5656fd1
commit 067af804ef
3 changed files with 13 additions and 3 deletions
@@ -22,12 +22,15 @@ public sealed class NonCompliantProjectEvent : IEvent
}
public sealed class NonCompliantProjectEventHandler(IDbContextFactory<ApplicationDbContext> contextFactory,
ICommunicationsService service) : INotificationHandler<NonCompliantProjectEvent>
IServiceProvider provider) : INotificationHandler<NonCompliantProjectEvent>
{
public async ValueTask Handle(NonCompliantProjectEvent notification, CancellationToken cancellationToken)
{
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
var scope = provider.CreateScope().ServiceProvider;
var service = scope.GetRequiredService<ICommunicationsService>();
var now = DateTime.UtcNow;
// Fetch active/monitored projects with programme, portfolio, and award organisations