Beispiel #1
0
        public async Task WhenCalled_ShouldCallWeatherProvider()
        {
            // arrange

            // act
            await _subject.GetAsync(new[] { _request });

            // assert
            _weatherDataProviderMock.Verify(x => x.GetCityForecastAsync(_request.Id), Times.Once);
        }
        public async Task <IActionResult> Get(string cities)
        {
            if (string.IsNullOrWhiteSpace(cities))
            {
                return(BadRequest());
            }

            var requests = cities.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => GetCityRequest.Create(int.Parse(x)));
            var result   = await _weatherService.GetAsync(requests);

            return(Ok(result));
        }
        public async Task <GetWeatherResponse> Get([FromQuery] GetWeatherRequest request)
        {
            var weatherResponse = await _weatherService.GetAsync(request.ZipCode, request.Units);

            var timeZoneResponse = await _timeZoneService.GetAsync(
                weatherResponse.coord.lon.ToString(),
                weatherResponse.coord.lat.ToString(),
                weatherResponse.dt.ToString());

            var result = _mapper.Map <GetWeatherResponse>(weatherResponse);

            result.TimeZone = timeZoneResponse.timeZoneName;

            return(result);
        }
        public async Task <IActionResult> Get(string city)
        {
            var result = await _weatherService.GetAsync(city);

            return(Ok(result));
        }
 public async Task <ActionResult> Index()
 {
     return(View(await _weatherService.GetAsync()));
 }