public WeatherForecast ToDomainEntities(AccuweatherForecastDTO accuweatherForecastDTO, AccuWeatherLocationDTO location) { List <Weather> weatherList = new List <Weather>(); foreach (var forecastWeather in accuweatherForecastDTO.DailyForecasts) { weatherList.Add(ConvertForecastModel(forecastWeather)); } var city = ToWeatherCity(location); return(new WeatherForecast { City = city, WeatherList = weatherList }); }
public async Task <WeatherForecast> GetForecast(string city, int days) { var location = await GetLocationByNameAsync(city); UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"forecasts/v1/daily/{NumberOfDays(days)}day/{location.Key}", Query = $"apikey={_serviceKey}&language={_lang}&metric={!_isImperial}" }; AccuweatherForecastDTO weatherResponse = await _requestService.GetAsync <AccuweatherForecastDTO>(builder.Uri); AccuweatherMapper accuweatherMapper = new AccuweatherMapper(); WeatherForecast weatherForecast = accuweatherMapper.ToDomainEntities(weatherResponse, location); return(weatherForecast); }