public IQueryable <Department> LoadSearchEntities(SearchDepParam searchDepParam) { short delNormal = (short)DelFlagEnum.Normal; var temp = GetCurrentDbSession.DepartmentDal.LoadEntities(u => u.DelFlag == delNormal); //Fileter by username search criteria if (!string.IsNullOrEmpty(searchDepParam.SName)) { temp = temp.Where(u => u.DepName.Contains(searchDepParam.SName)); } searchDepParam.Total = temp.Count(); return(temp.OrderBy(u => u.ID).Skip(searchDepParam.PageSize * (searchDepParam.PageIndex - 1)) .Take(searchDepParam.PageSize).AsQueryable()); }
/// <summary> /// Get users according to the search criteria /// </summary> /// <param name="SName">Searching string of user name</param> /// <param name="SMail">Searching string of user user email</param> /// <returns></returns> public ActionResult GetAllDepartments() { //Get the page size and page index from front end. int pageSize = Request["rows"] == null ? 10 : int.Parse(Request["rows"]); int pageIndex = Request["page"] == null ? 1 : int.Parse(Request["page"]); short delNormal = (short)DelFlagEnum.Normal; SearchDepParam depParam = new SearchDepParam(); depParam.PageSize = pageSize; depParam.PageIndex = pageIndex; depParam.SName = Request["name"]; var pagedData = departmentService.LoadSearchEntities(depParam); var userList = userInfoService.LoadEntities(u => u.DelFlag == delNormal); //Assembe the data into EasyUI table data, like : {total: 10; rows:[]} //Sovle the issue of loop dependency caused by navigation properties when serialising the data to Json var data = new { total = depParam.Total, rows = (from u in pagedData join user in userList on u.DepMasterId equals user.ID select new { u.ID, u.DepName, user.UserName, u.DepNo, u.TreePath } ).ToList() }; return(Json(data, JsonRequestBehavior.AllowGet)); }