예제 #1
0
        public async Task <IEnumerable <ForecastChart> > GetForecastChart([FromQuery] string input)
        {
            _logger.Log(LogLevel.Information, $"Input = {input}");

            if (string.IsNullOrWhiteSpace(input))
            {
                return(new List <ForecastChart>());
            }

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

                return(response.list.Select(forecast =>
                                            _mapper.Map <List, ForecastChart>(forecast)).ToList());
            }
            else
            {
                var response = await _service.GetChartDataByName(input);

                return(response.list.Select(forecast =>
                                            _mapper.Map <List, ForecastChart>(forecast)).ToList());
            }
        }