using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;

namespace AjaxDestinations.Controllers
{
    public class LabSolutionsController : Controller
    {
        //
        // GET: /LabSolutions/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult PackageInfoJson()
        {
            return View();
        }

        public ActionResult PackageInfoJsonJquery()
        {
            return View();
        }

        public ActionResult UsersJquery()
        {
            return View();
        }

        public ActionResult AddUserJquery()
        {
            return View();
        }

        public ActionResult Yahoo()
        {
            return View();
        }

        public ActionResult Tweets()
        {
            return View();
        }

        public ActionResult CountryDetails()
        {
            return View();
        }

        public ActionResult CountryDetailsProxy(string country)
        {
            XElement rootXml = XElement.Load("http://ws.geonames.org/countryInfo?country=" + country);
            var result = (from c in rootXml.Elements()
                           select new
                                      {
                                          Code = (string) c.Element("countryCode"),
                                          Name = (string) c.Element("countryName"),
                                          Capital = (string) c.Element("capital"),

                                      }).FirstOrDefault();
            return Json(result, JsonRequestBehavior.AllowGet);
        }

    }
}
