private void updateWith10DayData(string response)
        {
            var    json = JObject.Parse(response);
            JToken forecastToken;

            if (!json.TryGetValue("forecast", out forecastToken))
            {
                var tc         = new Microsoft.ApplicationInsights.TelemetryClient();
                var properties = new Dictionary <String, string> {
                    { "response", response }
                };
                tc.TrackEvent($"Unexpected response in {nameof(updateWith10DayData)}", properties);
                return;
            }
            var allDaily      = forecastToken["simpleforecast"]["forecastday"].Children();
            var dailyForecast = new List <WeatherDetailsModel>();

            foreach (var daily in allDaily.Take(10))
            {
                var rawEpoch = Int64.Parse(daily["date"]["epoch"].ToString());
                var epoch    = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
                var forecast = new WeatherDetailsModel()
                {
                    Conditions      = daily["conditions"].ToString(),
                    TemperatureHigh = Int32.Parse(daily["high"]["celsius"].ToString()),
                    TemperatureLow  = Int32.Parse(daily["low"]["celsius"].ToString()),
                    Rainfall        = Int32.Parse(daily["qpf_allday"]["mm"].ToString()),
                    Snowfall        = Int32.Parse(daily["snow_allday"]["cm"].ToString()),
                    Time            = epoch.DateTime,
                };
                dailyForecast.Add(forecast);
            }
            DailyForecast = dailyForecast;
        }
        private void updateWithHourlyData(string response)
        {
            var    json = JObject.Parse(response);
            JToken allHourly;

            if (!json.TryGetValue("hourly_forecast", out allHourly))
            {
                var tc         = new Microsoft.ApplicationInsights.TelemetryClient();
                var properties = new Dictionary <String, string> {
                    { "response", response }
                };
                tc.TrackEvent($"Unexpected response in {nameof(updateWithHourlyData)}", properties);
                return;
            }
            var hourlyForecast = new List <WeatherDetailsModel>();

            foreach (var hourly in allHourly.Take(24))
            {
                var rawEpoch = Int64.Parse(hourly["FCTTIME"]["epoch"].ToString());
                var epoch    = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
                var forecast = new WeatherDetailsModel()
                {
                    Conditions  = hourly["condition"].ToString(),
                    Temperature = Int32.Parse(hourly["temp"]["metric"].ToString()),
                    Rainfall    = Int32.Parse(hourly["qpf"]["metric"].ToString()),
                    Snowfall    = Int32.Parse(hourly["snow"]["metric"].ToString()),
                    Time        = epoch.DateTime,
                };
                hourlyForecast.Add(forecast);
            }
            HourlyForecast = hourlyForecast;
        }
 private void updateWith10DayData(string response)
 {
     var json = JObject.Parse(response);
     var allDaily = json["forecast"]["simpleforecast"]["forecastday"].Children();
     var dailyForecast = new List<WeatherDetailsModel>();
     foreach (var daily in allDaily.Take(10))
     {
         var rawEpoch = Int64.Parse(daily["date"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = daily["conditions"].ToString(),
             TemperatureHigh = Int32.Parse(daily["high"]["celsius"].ToString()),
             TemperatureLow = Int32.Parse(daily["low"]["celsius"].ToString()),
             Rainfall = Int32.Parse(daily["qpf_allday"]["mm"].ToString()),
             Snowfall = Int32.Parse(daily["snow_allday"]["cm"].ToString()),
             Time = epoch.DateTime,
         };
         dailyForecast.Add(forecast);
     }
     DailyForecast = dailyForecast;
 }
 private void updateWithHourlyData(string response)
 {
     var json = JObject.Parse(response);
     var allHourly = json["hourly_forecast"];
     var hourlyForecast = new List<WeatherDetailsModel>();
     foreach (var hourly in allHourly.Take(24))
     {
         var rawEpoch = Int64.Parse(hourly["FCTTIME"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = hourly["condition"].ToString(),
             Temperature = Int32.Parse(hourly["temp"]["metric"].ToString()),
             Rainfall = Int32.Parse(hourly["qpf"]["metric"].ToString()),
             Snowfall = Int32.Parse(hourly["snow"]["metric"].ToString()),
             Time = epoch.DateTime,
         };
         hourlyForecast.Add(forecast);
     }
     HourlyForecast = hourlyForecast;
 }
 private void updateWith10DayData(string response)
 {
     var json = JObject.Parse(response);
     JToken forecastToken;
     if (!json.TryGetValue("forecast", out forecastToken))
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "response", response } };
         tc.TrackEvent($"Unexpected response in {nameof(updateWith10DayData)}", properties);
         return;
     }
     var allDaily = forecastToken["simpleforecast"]["forecastday"].Children();
     var dailyForecast = new List<WeatherDetailsModel>();
     foreach (var daily in allDaily.Take(10))
     {
         var rawEpoch = Int64.Parse(daily["date"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = daily["conditions"].ToString(),
             TemperatureHigh = Int32.Parse(daily["high"]["celsius"].ToString()),
             TemperatureLow = Int32.Parse(daily["low"]["celsius"].ToString()),
             Rainfall = Int32.Parse(daily["qpf_allday"]["mm"].ToString()),
             Snowfall = Int32.Parse(daily["snow_allday"]["cm"].ToString()),
             Time = epoch.DateTime,
         };
         dailyForecast.Add(forecast);
     }
     DailyForecast = dailyForecast;
 }
 private void updateWithHourlyData(string response)
 {
     var json = JObject.Parse(response);
     JToken allHourly;
     if (!json.TryGetValue("hourly_forecast", out allHourly))
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "response", response } };
         tc.TrackEvent($"Unexpected response in {nameof(updateWithHourlyData)}", properties);
         return;
     }
     var hourlyForecast = new List<WeatherDetailsModel>();
     foreach (var hourly in allHourly.Take(24))
     {
         var rawEpoch = Int64.Parse(hourly["FCTTIME"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = hourly["condition"].ToString(),
             Temperature = Int32.Parse(hourly["temp"]["metric"].ToString()),
             Rainfall = Int32.Parse(hourly["qpf"]["metric"].ToString()),
             Snowfall = Int32.Parse(hourly["snow"]["metric"].ToString()),
             Time = epoch.DateTime,
         };
         hourlyForecast.Add(forecast);
     }
     HourlyForecast = hourlyForecast;
 }