public async Task DoWorkAsync() { using (var scope = _services.CreateScope()) { IGamestatusService _gamestatusService = scope.ServiceProvider.GetRequiredService <IGamestatusService>(); IGameEvolutionService _gameEvolutionService = scope.ServiceProvider.GetRequiredService <IGameEvolutionService>(); GameStatusDto gameStatus = await _gamestatusService.GetGameStatusAsync(); GameStatusDto nextGeneration = _gameEvolutionService.Evolve(gameStatus); await _gamestatusService.SetGameStatusAsync(nextGeneration); if (_hubContext?.Clients?.All != null) { await _hubContext?.Clients?.All?.SendAsync("Notify", nextGeneration); } _logger.LogInformation("Timed Background Service is working."); } }
public GameStatusController(IGameEvolutionService gameEvolutionService) { _gameEvolutionService = gameEvolutionService; }