/// <summary> /// Store response from OpenWeatherMap /// </summary> /// <param name="cityName">City name</param> /// <returns>Status</returns> public async Task <bool> GetData(string cityName) { // Send request var responseWeather = await _getResponse(cityName); var responseForecast = await _getResponse(cityName, "forecast"); // Check for success status code if (!responseWeather.IsSuccessStatusCode || !responseForecast.IsSuccessStatusCode) { return(false); } // Save data for weather var responseWeatherResult = await responseWeather.Content.ReadAsStringAsync(); Weather = WeatherModel.FromJson(responseWeatherResult); // Save data for forecast var responseForecastResult = await responseForecast.Content.ReadAsStringAsync(); Forecast = ForecastModel.FromJson(responseForecastResult); return(true); }
public static string ToJson(this ForecastModel self) => JsonConvert.SerializeObject(self, Converter.Settings);