private static WeatherData ConvertSerializedRawDataIntoWeatherData(string zipCode, RawSerializedWeatherData rawSerializedWeatherData) { System.DateTime sunrise = CalculateTimeAsUtc(rawSerializedWeatherData.sys.sunrise); System.DateTime sunset = CalculateTimeAsUtc(rawSerializedWeatherData.sys.sunset); WeatherData weatherData = new WeatherData(); weatherData.cityName = rawSerializedWeatherData.name; weatherData.zipCode = zipCode; weatherData.currentTemp = rawSerializedWeatherData.main.temp; weatherData.weatherType = rawSerializedWeatherData.weather[0].main; weatherData.sunrise = sunrise; weatherData.sunset = sunset; return weatherData; }
private static WeatherData GetWeatherData(string zipCode, string openWeatherMapJson) { WeatherData weatherData = new WeatherData(); try { RawSerializedWeatherData rawWeatherData = ConvertJsonIntoSerializedRawWeatherData(openWeatherMapJson); weatherData = ConvertSerializedRawDataIntoWeatherData(zipCode, rawWeatherData); } catch (Exception e) { return new WeatherData(); } return weatherData; }