diff --git a/backend/src/StamAcasa.Api/BackgroundServices/UserManagementService.cs b/backend/src/StamAcasa.Api/BackgroundServices/UserManagementService.cs index f390a1b2..50d35d77 100644 --- a/backend/src/StamAcasa.Api/BackgroundServices/UserManagementService.cs +++ b/backend/src/StamAcasa.Api/BackgroundServices/UserManagementService.cs @@ -9,16 +9,18 @@ namespace StamAcasa.Api.BackgroundServices { + using Microsoft.Extensions.DependencyInjection; + public class UserManagementService : BackgroundService { private readonly ILogger _logger; private readonly IQueueService _queueService; - private readonly IUserService _userService; + private readonly IServiceProvider _serviceProvider; - public UserManagementService(IQueueService queueService, IUserService userService, ILogger logger) + public UserManagementService(IQueueService queueService, IServiceProvider serviceProvider, ILogger logger) { _queueService = queueService; - _userService = userService; + _serviceProvider = serviceProvider; _logger = logger; } @@ -31,9 +33,10 @@ public override Task StartAsync(CancellationToken cancellationToken) { try { + var userService = _serviceProvider.GetService(); _logger.LogInformation($"Will soft delete user with sub= {request.Sub}"); - await _userService.MarkUserAsDeleted(request.Sub); + await userService.MarkUserAsDeleted(request.Sub); _logger.LogInformation($"Done soft delete of user with sub= {request.Sub}"); }