Ejemplo n.º 1
0
        public JsonResult SearchServerSide()
        {
            // Get Server Side Parameters from Request
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Convert.ToInt32(Request["length"]);
            string searchValue    = Request["search[value]"];
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];

            // Total record count
            int totalrows = workOrdersRepo.GetAll().Count();

            // Search
            var searchResults           = WorkOrdersRepo.Find(searchValue);
            int totalrowsafterfiltering = searchResults.Count();

            // Sort
            searchResults = searchResults.OrderBy(sortColumnName + " " + sortDirection);

            // Page
            searchResults = searchResults.Skip(start).Take(length).ToList();

            return(Json(new { data = searchResults, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrowsafterfiltering }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult Search(string searchstring)
        {
            var searchResults = WorkOrdersRepo.Find(searchstring).ToList();

            return(Json(searchResults));
        }