public async Task AddReadingAsync(NwsLatestObservationDto observationDto) { TemperatureReading reading = new TemperatureReading((int)observationDto.Properties.Temperature.Value, TemperatureSource.Exterior); await _repository.AddReadingAsync(reading); await _repository.SaveChangesAsync(); }
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); } }