public async Task <WeatherData> GetWeather(string city) { var location = await GetLocationByNameAsync(city); UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"currentconditions/v1/{location.Key}", Query = $"apikey={_serviceKey}&language={_lang}&details=true" }; IEnumerable <AccuweatherDTO> weatherResponse = await _requestService.GetAsync <IEnumerable <AccuweatherDTO> >(builder.Uri); AccuweatherMapper accuweatherMapper = new AccuweatherMapper(); WeatherData weather = accuweatherMapper.ToDomainEntity(weatherResponse.First(), location, _isImperial); return(weather); }
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); }