Ejemplo n.º 1
0
    public async Task <IEnumerable <WeatherForecastDto> > Handle(GetWeatherForecastsQuery request,
                                                                 CancellationToken cancellationToken)
    {
        var weatherForecasts = await _weatherForecastRepo.GetAllAsync();

        return(weatherForecasts.Select(_mapper.Map <WeatherForecastDto>).ToList());
    }
        public async Task ShouldReturnAllListsAndItems()
        {
            var query = new GetWeatherForecastsQuery();

            var result = await SendAsync(query);

            result.Should().NotBeNull();
            result.Data.Should().NotBeEmpty();
            result.Data.Should().HaveCount(5);
        }
Ejemplo n.º 3
0
    protected override IEnumerable <WeatherForecast> Handle(GetWeatherForecastsQuery request)
    {
        var rng = new Random();

        return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
        {
            Date = DateTime.Now.AddDays(index),
            TemperatureC = rng.Next(-20, 55),
            Summary = Summaries[rng.Next(Summaries.Length)]
        }));
    }
Ejemplo n.º 4
0
        public Task <IEnumerable <WeatherForecastDTO> > Get()
        {
            _logger.LogTrace("LogTrace Get IEnumerable<WeatherForecast>");
            _logger.LogDebug("LogDebug Get IEnumerable<WeatherForecast>");
            _logger.LogInformation("LogInformation Get IEnumerable<WeatherForecast>");
            _logger.LogWarning("LogWarning Get IEnumerable<WeatherForecast>");
            _logger.LogError("LogError Get IEnumerable<WeatherForecast>");
            _logger.LogCritical("LogCritical Get IEnumerable<WeatherForecast>");

            return(GetWeatherForecastsQuery.Handle());
        }
Ejemplo n.º 5
0
            public Task <IEnumerable <WeatherForecast> > Handle(GetWeatherForecastsQuery request, CancellationToken cancellationToken)
            {
                var rng = new Random();
                var vm  = Enumerable.Range(1, 5).Select(index => new WeatherForecast
                {
                    Date         = DateTime.Now.AddDays(index),
                    TemperatureC = rng.Next(-20, 55),
                    Summary      = Summaries[rng.Next(Summaries.Length)]
                });

                return(Task.FromResult(vm));
            }
Ejemplo n.º 6
0
        public async Task <WeatherForecast> Get([FromQuery] GetWeatherForecastsQuery query)
        {
            var result = await _mediatorService.Send <GetWeatherForecastsQuery, WeatherForecast>(query);

            return(result);
        }
        public async Task <IActionResult> Get([FromQuery] GetWeatherForecastsQuery query, CancellationToken cancellationToken = default)
        {
            IEnumerable <WeatherForecastDetails> result = await Mediator.Send(query, cancellationToken);

            return(Ok(result));
        }