Example #1
0
        public async Task <IEnumerable <WeatherObservationDto> > Get()
        {
            var observations = await _weatherRepository.GetAll();

            return(observations.Select(o => new WeatherObservationDto
            {
                Date = o.Date,
                TemperatureC = o.TemperatureC,
                TemperatureF = o.TemperatureF,
                Summary = o.Summary
            }));
        }
Example #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation($"Worker running at {DateTime.Now}");
                foreach (var weather in await _weatherRepository.GetAll())
                {
                    _logger.LogInformation($"removing {weather.Id}");
                    await _weatherRepository.Delete(weather.Id);

                    await Task.Delay(TimeSpan.FromSeconds(2), stoppingToken);
                }
                await Task.Delay(TimeSpan.FromSeconds(30), stoppingToken);
            }
        }
Example #3
0
 public IEnumerable <WeatherForecast> GetAll()
 {
     return(weatherRepository.GetAll());
 }
        public async Task <GetAllResponse> Handle(GetAllRequest request, CancellationToken cancellationToken)
        {
            var currentsWeather = await _repository.GetAll();

            return(_mapper.Map <GetAllResponse>(currentsWeather.Select(_mapper.Map <GetResponse>)));
        }
Example #5
0
 public PaginatingResultDto <WeatherForecast> GetAll(
     [FromQuery] int skipCount      = 0,
     [FromQuery] int?maxResultCount = 10)
 {
     return(repository.GetAll(skipCount, maxResultCount));
 }