public async Task <WeatherData> GetWeather(double latitude, double longitude) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"data/2.5/onecall", Query = $"lat={latitude.ToString(CultureInfo.InvariantCulture)}&lon={longitude.ToString(CultureInfo.InvariantCulture)}&exclude=minutely,hourly,daily,alerts&lang={_lang}&units={_unit}&appid={_serviceKey}" }; OpenWeatherMapDTO weatherResponse = await _requestService.GetAsync <OpenWeatherMapDTO>(builder.Uri); OpenWeatherMapMapper openWeatherMapMapper = new OpenWeatherMapMapper(); WeatherData weather = openWeatherMapMapper.ToDomainEntity(weatherResponse, _runtimeContext.CityName); return(weather); }
public async Task <WeatherForecast> GetForecast(double latitude, double longitude, int days) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"data/2.5/onecall", Query = $"lat={latitude.ToString(CultureInfo.InvariantCulture)}&lon={longitude.ToString(CultureInfo.InvariantCulture)}&exclude=current,minutely,hourly,alerts&lang={_lang}&units={_unit}&appid={_serviceKey}" }; OpenWeatherMapForecastDTO weatherResponse = await _requestService.GetAsync <OpenWeatherMapForecastDTO>(builder.Uri); OpenWeatherMapMapper openWeatherMapMapper = new OpenWeatherMapMapper(); WeatherForecast weatherForecast = openWeatherMapMapper.ToDomainEntities(weatherResponse, _runtimeContext.CityName); var indexOfTodaysWeahterItem = weatherForecast.WeatherList.FindIndex(x => x.Date.Date == DateTime.Now.Date); weatherForecast.WeatherList = weatherForecast.WeatherList.GetRange(indexOfTodaysWeahterItem, days); return(weatherForecast); }