public JsonResult ListByPage(int pageNumber)
        {
            ReturnProgramPdtCtrlHistory _returnProgramPdtCtrlHistory = programPdtCtrlHistory.ListbyPage(pageNumber, pageSize);

            _returnProgramPdtCtrlHistory.TotalPage = (_returnProgramPdtCtrlHistory.Total + pageSize - 1) / pageSize;
            _returnProgramPdtCtrlHistory.TotalPage = _returnProgramPdtCtrlHistory.TotalPage == 0 ? 1 : _returnProgramPdtCtrlHistory.TotalPage;


            return(Json(_returnProgramPdtCtrlHistory, JsonRequestBehavior.AllowGet));
        }
        //public JsonResult Search(ReturnProgramPdtCtrlHistory searchProgrampdtCtrl)
        //{
        //    ReturnProgramPdtCtrlHistory _returnProgramPdtCtrlHistory = programPdtCtrlHistory.SearchProgramPdtCtrlHistory(searchProgrampdtCtrl, pageSize);
        //    _returnProgramPdtCtrlHistory.TotalPage = (_returnProgramPdtCtrlHistory.Total + pageSize - 1) / pageSize;
        //    _returnProgramPdtCtrlHistory.TotalPage = _returnProgramPdtCtrlHistory.TotalPage == 0 ? 1 : _returnProgramPdtCtrlHistory.TotalPage;
        //    //JsonResult x = Json(_returnToolList, JsonRequestBehavior.AllowGet);
        //    //string y = new JavaScriptSerializer().Serialize(jsonResult.Data);
        //    //string y = Newtonsoft.Json.JsonConvert.SerializeObject(x.Data);

        //    return Json(_returnProgramPdtCtrlHistory, JsonRequestBehavior.AllowGet);
        //}
        public JsonResult Search([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, ProgramPdtCtrlHistory searchProgrampdtCtrl)
        {
            //DataTables.
            int pageSize   = requestModel.Length != 0 ? requestModel.Length : 10;
            int pageNumber = requestModel.Start / requestModel.Length + 1;



            //Execute.
            ReturnProgramPdtCtrlHistory _returnProgramPdtCtrlHistory = programPdtCtrlHistory.SearchProgramPdtCtrlHistory(searchProgrampdtCtrl, pageNumber, pageSize);

            // DataTables.
            // Avoid from datatables.net getting stuck (if data=null).
            if (_returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory == null)
            {
                _returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = new List <ProgramPdtCtrlHistory>();
            }
            //Sorting
            var sortedColumns = requestModel.Columns.GetSortedColumns();
            var orderByString = String.Empty;

            foreach (var column in sortedColumns)
            {
                orderByString += orderByString != String.Empty ? "," : "";
                if (column.Data.Contains("Action"))
                {
                    continue;
                }
                orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
            }

            IEnumerable <ProgramPdtCtrlHistory> IEnum_ProgramPdtCtrlHistory = _returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory.OrderBy(orderByString ==
                                                                                                                                            string.Empty ? "ProgramName asc" : orderByString);

            _returnProgramPdtCtrlHistory.lstProgramPdtCtrlHistory = IEnum_ProgramPdtCtrlHistory.ToList <ProgramPdtCtrlHistory>();

            //Permission.
            _returnProgramPdtCtrlHistory.permisionControllerVM = this.getPermisionControllerViewModel();

            //DataTables.
            //return View.
            var DataTablesResponse = new
            {
                draw            = requestModel.Draw,
                data            = _returnProgramPdtCtrlHistory,
                recordsFiltered = _returnProgramPdtCtrlHistory.Total,
                recordsTotal    = _returnProgramPdtCtrlHistory.Total
            };

            return(Json(DataTablesResponse, JsonRequestBehavior.AllowGet));



            //ReturnProgramPdtCtrlHistory _returnProgramPdtCtrlHistory = programPdtCtrlHistory.SearchProgramPdtCtrlHistory(searchProgrampdtCtrl, pageNumber, pageSize);
            //_returnProgramPdtCtrlHistory.TotalPage = (_returnProgramPdtCtrlHistory.Total + pageSize - 1) / pageSize;
            //_returnProgramPdtCtrlHistory.TotalPage = _returnProgramPdtCtrlHistory.TotalPage == 0 ? 1 : _returnProgramPdtCtrlHistory.TotalPage;
            //JsonResult x = Json(_returnToolList, JsonRequestBehavior.AllowGet);
            //string y = new JavaScriptSerializer().Serialize(jsonResult.Data);
            //string y = Newtonsoft.Json.JsonConvert.SerializeObject(x.Data);

            return(Json(_returnProgramPdtCtrlHistory, JsonRequestBehavior.AllowGet));
        }