Exemplo n.º 1
0
        public async Task AddReadingAsync(NwsLatestObservationDto observationDto)
        {
            TemperatureReading reading =
                new TemperatureReading((int)observationDto.Properties.Temperature.Value, TemperatureSource.Exterior);

            await _repository.AddReadingAsync(reading);

            await _repository.SaveChangesAsync();
        }
Exemplo n.º 2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                NwsLatestObservationDto observationDto = await _nwsClient.GetLatestWeatherObservationAsync();

                _logger.LogInformation($"Exterior Temperature: {observationDto.Properties.Temperature.Value}C");
                await _temperatureReadingService.AddReadingAsync(observationDto);

                await Task.Delay(TimeSpan.FromMinutes(30), stoppingToken);
            }
        }