Пример #1
0
        public async Task <Weather> GetWeather([FromQuery] string input)
        {
            _logger.Log(LogLevel.Information, $"Input = {input}");

            if (string.IsNullOrWhiteSpace(input))
            {
                return(new Weather());
            }

            if (int.TryParse(input, out var zipcode))
            {
                var response = await _service.GetWeatherByZipCode(zipcode.ToString());

                var result = _mapper.Map <WeatherService.CurrentWeather, Weather>(response);
                return(result);
            }
            else
            {
                var response = await _service.GetWeatherByName(input);

                var result = _mapper.Map <WeatherService.CurrentWeather, Weather>(response);
                return(result);
            }
        }