diff --git a/PostFundManagement.Application/Events/LateProjectReminderEvent.cs b/PostFundManagement.Application/Events/LateProjectReminderEvent.cs index 5113ec9..69d1016 100644 --- a/PostFundManagement.Application/Events/LateProjectReminderEvent.cs +++ b/PostFundManagement.Application/Events/LateProjectReminderEvent.cs @@ -20,7 +20,7 @@ public sealed class LateProjectEvent : IEvent } public sealed class LateProjectEventHandler(IDbContextFactory contextFactory, - ICommunicationsService service) : INotificationHandler + IServiceProvider provider) : INotificationHandler { readonly int lateDays = 3; @@ -28,6 +28,9 @@ public sealed class LateProjectEventHandler(IDbContextFactory(); + var now = DateTime.UtcNow; var overdueCutoff = lateDays > 0 ? now.AddDays(-lateDays) : now; diff --git a/PostFundManagement.Application/Events/NonCompliantProjectEvent.cs b/PostFundManagement.Application/Events/NonCompliantProjectEvent.cs index 01da4a8..61e7b00 100644 --- a/PostFundManagement.Application/Events/NonCompliantProjectEvent.cs +++ b/PostFundManagement.Application/Events/NonCompliantProjectEvent.cs @@ -22,12 +22,15 @@ public sealed class NonCompliantProjectEvent : IEvent } public sealed class NonCompliantProjectEventHandler(IDbContextFactory contextFactory, - ICommunicationsService service) : INotificationHandler + IServiceProvider provider) : INotificationHandler { 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(); + var now = DateTime.UtcNow; // Fetch active/monitored projects with programme, portfolio, and award organisations diff --git a/PostFundManagement.Application/Events/ProcessEmailEvent.cs b/PostFundManagement.Application/Events/ProcessEmailEvent.cs index d516867..601b573 100644 --- a/PostFundManagement.Application/Events/ProcessEmailEvent.cs +++ b/PostFundManagement.Application/Events/ProcessEmailEvent.cs @@ -18,7 +18,7 @@ public sealed class ProcessEmailEvent : IEvent } public sealed class ProcessEmailEventHandler(IDbContextFactory contextFactory, - IFeatureManager featureManager, EmailService emailService, ISkorubaUserService skorubaUserService) : INotificationHandler + IServiceProvider provider, IFeatureManager featureManager) : INotificationHandler { const int maxBatch = 100; @@ -26,6 +26,10 @@ public sealed class ProcessEmailEventHandler(IDbContextFactory(); + var skorubaUserService = scope.GetRequiredService(); + await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); var outgoing = await context.Notifications.AsNoTracking()