Ejemplo n.º 1
0
        public async Task <Timetable> Get(int id)
        {
            _logger.LogInformation("Get timetable route accessed");
            await _timetableProvider.FetchCoursesAsync();

            return(_timetableProvider.Timetable);
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                Console.WriteLine("BackgroundProvider is attempting Courses fetch...");
                await _timetableProvider.FetchCoursesAsync();

                Console.WriteLine("Data fetch executed successfully at: " + _timetableProvider.Timetable.UpdatedAt);
                Console.WriteLine("Synchronizing StateGenerator data...");
                _stateGenerator.SyncDataWithProvider();
                await Task.Delay(TimeSpan.FromSeconds(30), stoppingToken);

                Console.WriteLine();
            }
            Console.WriteLine("BackgroundProvider background task is stopping.");
        }