Ejemplo n.º 1
0
        public ActionResult Index(SearchItemModel model)
        {
            //var model = new SearchItemModel();
            if (string.IsNullOrEmpty(model.SearchWords))
            {
                model.Result = null;
                return Json(model, JsonRequestBehavior.AllowGet);
            }

            var client = new CourseCatalogServiceReference.CourseClient();
            var result = client.Search(
                model.SearchWords
                , string.Empty
                , string.Empty
                , string.Empty
                , string.Empty
                , string.Empty
                , string.Empty
                , string.Empty
                , "2012/2013"
                , string.Empty
                , "CourseCode"
                );

            if (string.IsNullOrEmpty(result))
            {
                model.Result = null;
                return Json(model, JsonRequestBehavior.AllowGet);
            }

            
            var resultDocument = XDocument.Parse(result);
            model.Result = new List<SearchResultModel>();
            foreach (XElement element in resultDocument.Descendants("CourseInformation"))
            {
                model.Result.Add(new SearchResultModel {CourseCode = element.Attribute("CourseCode").Value});
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
 public ActionResult Index()
 {
     var model = new SearchItemModel();
     return View(model);
 }