public virtual WeatherNodes GetXMLForWeather(WeatherLocation i_Location)
        {
            bool          foundWeather  = false;
            XmlReader     reader        = null;
            XmlSerializer serializerObj = null;
            WeatherNodes  loadedObj     = null;

            ///Try with the event location first,if not found get the default
            while (foundWeather == false)
            {
                string url = string.Format(@"http://api.openweathermap.org/data/2.5/forecast?q={0},{1}&units=metric&mode=xml&appid=d6c795304f427b8b78559ab660464d80", i_Location.City, i_Location.CountryIsoCode);
                try
                {
                    reader        = XmlReader.Create(url);
                    foundWeather  = true;
                    serializerObj = new XmlSerializer(typeof(WeatherNodes));
                    loadedObj     = (WeatherNodes)serializerObj.Deserialize(reader);
                }
                catch (Exception ex)
                {
                    ////Handle case for city not found from this API:
                    if (ex is WebException)
                    {
                        WebException webExp = ex as WebException;

                        if (!(webExp == null) && ((WebException)ex).Status == WebExceptionStatus.ProtocolError)
                        {
                            HttpWebResponse resp = webExp.Response as HttpWebResponse;

                            if (resp != null && resp.StatusCode == HttpStatusCode.NotFound)
                            {
                                throw new WeatherException(string.Format("Could not find selected event location! setting to default values({0}, {1}", DefaultCity, DefaultCountry));
                            }
                        }
                    }
                    else
                    {
                        throw ex;
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
            }

            return(loadedObj);
        }
        private Weather findEventDetails(WeatherNodes i_LoadedObj, Event i_SelectedEvent)
        {
            Weather eventWeather = null;

            foreach (Weather obj in i_LoadedObj.WeatherList)
            {
                if (i_SelectedEvent.StartTime >= obj.FromTime && i_SelectedEvent.StartTime <= obj.ToTime)
                {
                    eventWeather = obj;
                }
            }

            m_TempInfo.Add("WeatherCode", string.Format("http://openweathermap.org/img/w/{0}.png", eventWeather.WeatherSymbol.WeatherCode));

            return(eventWeather);
        }
        public Dictionary <string, string> GetWeatherForEvent(Event io_SelectedEvent, bool i_IsDefaultLocation)
        {
            WeatherLocation location;

            m_TempInfo.Clear();
            if (i_IsDefaultLocation)
            {
                location = getDefaultLocation();
            }
            else
            {
                getLocationForWeather(io_SelectedEvent, out location);
            }

            WeatherNodes loadedObj = GetXMLForWeather(location);

            Weather eventWeather = findEventDetails(loadedObj, io_SelectedEvent);

            recommendForWeather(eventWeather);
            return(m_TempInfo);
        }