public JsonResult GetFirms(string sidx, string sord, int page, int rows, bool _search, string searchField, string searchOper, string searchString) { var res = _FirmService.GetFirmList(); // var res = _adminService.GetMasterPackageList(); sord = (sord == null) ? "" : sord; int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; var PackageList = res.Select( t => new { t.FirmId, t.FirmName, t.FirmEmail, //t.SSN, //t.EmailAddress, //t.PhoneNumber }); //if (_search) //{ // switch (searchField) // { // case "PackageName": // PackageList = PackageList.Where(t => t.PackageName.Contains(searchString)); // break; // case "MonthlyRate": // PackageList = PackageList.Where(t => t.MonthlyRate.ToString().Contains(searchString)); // break; // case "YearlyRate": // PackageList = PackageList.Where(t => t.YearlyRate.ToString().Contains(searchString)); // break; // case "SetUpFee": // PackageList = PackageList.Where(t => t.SetUpFee.ToString().Contains(searchString)); // break; // } //} int totalRecords = PackageList.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (sord.ToUpper() == "DESC") { PackageList = PackageList.OrderByDescending(t => t.FirmId); PackageList = PackageList.Skip(pageIndex * pageSize).Take(pageSize); } else { PackageList = PackageList.OrderBy(t => t.FirmId); PackageList = PackageList.Skip(pageIndex * pageSize).Take(pageSize); } var jsonData = new { total = totalPages, page, records = totalRecords, rows = PackageList }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }