public async Task <WeatherForecast> GetForecast(double latitude, double longitude, int days) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = "v2.0/forecast/daily", Query = $"lat={latitude.ToString(CultureInfo.InvariantCulture)}&lon={longitude.ToString(CultureInfo.InvariantCulture)}&units={_unit}&days={days}&lang={_lang}&key={_serviceKey}" }; WeatherbitForecastDTO weatherResponse = await _requestService.GetAsync <WeatherbitForecastDTO>(builder.Uri); WeatherbitMapper weatherbitMapper = new WeatherbitMapper(); WeatherForecast weatherForecast = weatherbitMapper.ToDomainEntities(weatherResponse); return(weatherForecast); }
public async Task <WeatherForecast> GetForecast(string city, int days) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = "v2.0/forecast/daily", Query = $"city={city}&units={_unit}&days={days}&lang={_lang}&key={_serviceKey}" }; WeatherbitForecastDTO weatherResponse = await _requestService.GetAsync <WeatherbitForecastDTO>(builder.Uri); WeatherbitMapper weatherbitMapper = new WeatherbitMapper(); WeatherForecast weatherForecast = weatherbitMapper.ToDomainEntities(weatherResponse); return(weatherForecast); }
public WeatherForecast ToDomainEntities(WeatherbitForecastDTO weatherbitForecastDTO) { List <Weather> weatherList = new List <Weather>(); foreach (var forecastWeather in weatherbitForecastDTO.data) { weatherList.Add(ToWeather(forecastWeather)); } var city = ToWeatherCity(weatherbitForecastDTO); return(new WeatherForecast { City = city, WeatherList = weatherList }); }