public Location GetLocationInfo(LocationName location)
        {
            Location checkedLocation = new Location();

            //Create a new XML document, create the string from user input, and load the XML.
            XmlDocument xml = new XmlDocument();
            String xmlString = String.Format("http://api.geonames.org/search?q={0}&maxRows=10&lang=es&username=crippegoude&style=full", location.LocationString);
            xml.Load(xmlString);

            XmlNodeList xmlNodeList = xml.SelectNodes("/geonames/geoname");

            try
            {
                //Get the information from the first location found
                checkedLocation.LocationID = Convert.ToInt32(xmlNodeList[0]["geonameId"].InnerText);
                checkedLocation.Lat = xmlNodeList[0]["lat"].InnerText;
                checkedLocation.Lng = xmlNodeList[0]["lng"].InnerText;
                checkedLocation.Location1 = location.LocationString;
            }
            catch (XmlException)
            {
                throw new Exception();
            }
            return checkedLocation;
        }
        public ActionResult Search(LocationName location)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    locationFinder = new GeoWebService();
                    weatherFinder = new WeatherWebService();
                    checkedLocation = new Location();
                    checkedLocation = locationFinder.GetLocationInfo(location);

                    List<WeatherInfo> weatherList = new List<WeatherInfo>();
                    weatherList = weatherFinder.GetWeatherInfo(checkedLocation);

                    _repository.AddWeather(weatherList);
                    _repository.Save();

                    return View("Index", weatherList);
                }
                else
                {
                    return View("Search");
                }
            }
            catch (Exception e)
            {
                string error = "This city was not found in the Geonames API";
                ModelState.AddModelError(String.Empty, error + e.InnerException);
                return View("Search");
            }
        }