private PagedList<ProjectStructure> QueryListData(ProjectStructureSearch searchModel)
        {
            int recordCount = 0;
            int pageSize = ConstantManager.PageSize;
            ProjectStructureService service = new ProjectStructureService();

            string Group = searchModel.IsAsc ? searchModel.SortBy : searchModel.SortBy + " Descending";

            IList<ProjectStructure> allEntities = service.QueryByPage(this.GetSearchFilter(searchModel), Group, pageSize, searchModel.PageIndex + 1, out recordCount);

            var formCondition = "var condition=" + JsonConvert.SerializeObject(searchModel);
            return new PagedList<ProjectStructure>(allEntities, searchModel.PageIndex, pageSize, recordCount, "Id", "Id", formCondition);
        }
 private void LoadSearchViewBag(ProjectStructureSearch searchModel)
 {
     #region sort
     ViewBag.IsAsc = !searchModel.IsAsc;
     ViewBag.SortBy = searchModel.SortBy;
     #endregion
         var orgchartService = new OrgChartService();
         if (!searchModel.OrgChartId.HasValue)
         {
             ViewBag.OrgChartId = new SelectList(orgchartService.Query(p => p.IsActive=="1"), "Id", "Name");
         }
         else
         {
             ViewBag.OrgChartId = new SelectList(orgchartService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.OrgChartId);
         }
 }
 public ActionResult SearchListPartialView(ProjectStructureSearch searchModel)
 {
     #region sort
     ViewBag.IsAsc = !searchModel.IsAsc;
     ViewBag.SortBy = searchModel.SortBy;
     #endregion
     return PartialView("SearchListPartialView",this.QueryListData(searchModel));
 }
        private Expression<Func<ProjectStructure, bool>> GetSearchFilter(ProjectStructureSearch searchModel)
        {
            Expression<Func<ProjectStructure, bool>> filter = p => p.IsActive=="1" ;
                 if (searchModel.OrgChartId.HasValue)
                 {
                    filter = filter.And(q => q.OrgChartId == searchModel.OrgChartId.Value);
                 }

            return filter;
        }
 //
 // GET: /ProjectStructure/
 //[PermissionFilter]
 public ViewResult Index(ProjectStructureSearch searchModel)
 {
     this.LoadSearchViewBag(searchModel);
     return View(this.QueryListData(searchModel));
 }