private PagedList<Department> QueryListData(DepartmentSearch searchModel) { int recordCount = 0; int pageSize = ConstantManager.PageSize; DepartmentService service = new DepartmentService(); string Group = searchModel.IsAsc ? searchModel.SortBy : searchModel.SortBy + " Descending"; IList<Department> allEntities = service.QueryByPage(this.GetSearchFilter(searchModel), Group, pageSize, searchModel.PageIndex + 1, out recordCount); var formCondition = "var condition=" + JsonConvert.SerializeObject(searchModel); return new PagedList<Department>(allEntities, searchModel.PageIndex, pageSize, recordCount, "Id", "Id", formCondition); }
private void LoadSearchViewBag(DepartmentSearch 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(DepartmentSearch searchModel) { #region sort ViewBag.IsAsc = !searchModel.IsAsc; ViewBag.SortBy = searchModel.SortBy; #endregion return PartialView("SearchListPartialView",this.QueryListData(searchModel)); }
private Expression<Func<Department, bool>> GetSearchFilter(DepartmentSearch searchModel) { Expression<Func<Department, bool>> filter = p => p.IsActive=="1" ; if (searchModel.OrgChartId.HasValue) { filter = filter.And(q => q.OrgChartId == searchModel.OrgChartId.Value); } return filter; }
// // GET: /Department/ //[PermissionFilter] public ViewResult Index(DepartmentSearch searchModel) { this.LoadSearchViewBag(searchModel); return View(this.QueryListData(searchModel)); }