Exemple #1
0
        public ActionResult AirportSearch(string searchTerm, int pageSize, int pageNum)
        {
            var ca_o  = HttpRuntime.Cache["airports-data"];
            var sel_o = new Select2Result[] { new Select2Result {
                                                  id = "", text = "none"
                                              } };

            Suggest sg = new Suggest();

            Select2PagedResult aps_o = new Select2PagedResult
            {
                Total   = 1,
                Results = sel_o
            };

            try
            {
                if (ca_o != null)
                {
                    Airports[] all_airports = (Airports[])ca_o;

                    aps_o.Results = sg.Airports(searchTerm, all_airports);
                }
            } catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }


            return(new JsonResult
            {
                Data = aps_o,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemple #2
0
        public void Suggestions()
        {
            Suggest sg = new Suggest();

            Select2Result[] results = sg.Airports("", test_airports);

            // make sure airport suggestions return all values
            Assert.IsNotNull(results);

            Assert.AreEqual(4, results.Length);

            Suggest sg2 = new Suggest();

            Select2Result[] results_t2 = sg2.Airports("la", test_airports);

            Assert.AreEqual(2, results_t2.Length);

            Suggest sg3 = new Suggest();

            Select2Result[] results_t3 = sg3.Airports("sKY", test_airports);
            //check to see if airport names are being searched
            Assert.AreEqual(1, results_t3.Length);
        }