Esempio n. 1
0
        public ActionResult AutocompleteAsync(string term)
        {
            List<string> townList = new System.Collections.Generic.List<string>();
            using (AllConection tmp = new AllConection())
            {
                townList = (from a in tmp.Towns where a.name.StartsWith(term) select a.name).Take(10).ToList();
            }

            var ret = townList;
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
        public JsonResult AutocompleteSuggestions(string term)
        {
            /*   List<string> townList = new System.Collections.Generic.List<string>();
            using (DanicoProject.Models.AllConection tmp = new Models.AllConection())
            {
                var suggestions = from s in tmp.Towns select s.name;
                townList = suggestions.Where(n => n.ToLower().StartsWith(term.ToLower())).ToList();

            }*/

            AllConection db = new AllConection();
            var suggestions = from s in db.Towns select s.name;
            var namelist = suggestions.Where(n => n.ToLower().StartsWith(term.ToLower())).ToList();
            // return namelist.ToList();
            return Json(namelist, JsonRequestBehavior.AllowGet);
        }
Esempio n. 3
0
        public ActionResult Search(string search, string[] orderNumbers)
        {
            ViewBag.townFilter = search;
            ViewBag.checkList = orderNumbers;
            List<long?> serviceIdInDB = varHotel.getServiceID(orderNumbers);
            List<Models.Hotel> hotelList = new List<Models.Hotel>();

            using (AllConection tmp = new AllConection())
            {

                 //1s filter
                if (!String.IsNullOrEmpty(search))
                 {
                     hotelList = tmp.Hotels.Select(a => a).ToList();
                     long idTown = varHotel.getIdTown(search);
                     //2d filter
                     if (idTown > -1)
                     {
                         hotelList = hotelList.Where(s => s.fk_idTown.Equals(idTown)).ToList();
                         //3d filter
                         if (serviceIdInDB.Count > 0)
                         {
                             List<long> hotelListIDs = hotelList.ConvertAll(obj => obj.pk_idHotel).ToList();

                             hotelList =
                              (from hotel in tmp.Hotels
                               join service in tmp.HotelServices on hotel.pk_idHotel equals service.idHotel
                               where hotelListIDs.Contains(hotel.pk_idHotel)
                               where serviceIdInDB.Contains(service.idService)
                               select hotel).Distinct().ToList<Models.Hotel>();
                         }
                     }

                 }
            }
            return View(hotelList);
        }