async public Task <IEnumerable <WeatherForecast> > GetWeather(string cityName) { var repo = new OpenWeatherMapApiClient(); var resp = await repo.GetWeatherForecast(cityName); return(WeatherForecastConverter.ToWeatherForecast(resp)); }
private OpenWeatherMapApiClient CreateSut() { var sut = new OpenWeatherMapApiClient( FixtureElements.HttpClient, FixtureElements.JsonResponseMapper, FixtureElements.ApiConfiguration); return(sut); }
public override ActionResult Index(WeatherBlock currentBlock) { string unit = currentBlock.DisplayCelsius ? "C" : "F"; OpenWeatherMapApiClient client = new OpenWeatherMapApiClient("b6d85c82ae14e8d2819f6f5542565201", units: currentBlock.DisplayCelsius ? Units.Metric : Units.Imperial); var results = client.GetWeaterByCityNameAsync(currentBlock.City, currentBlock.Country).Result; WeatherBlockViewModel model = new WeatherBlockViewModel() { Heading = currentBlock.Heading, Location = currentBlock.City + ", " + currentBlock.Country, Windspeed = results.Wind.Speed, Humidity = results.Main.Humidity, Pressure = results.Main.Pressure, Time = results.Timestamp, Temperature = results.Main.Temperature, Unit = unit }; return(PartialView("WeatherDisplay", model)); }
public CurrentWeatherService(string openWeatherMapBaseAddress, string openWeatherMapAppId) { openWeatherMapApiClient = new OpenWeatherMapApiClient(new Uri(openWeatherMapBaseAddress), new AddAppIdMessageHandler(openWeatherMapAppId)); }