public IActionResult Index(PageParameter pageParams) { PageDataResponse <UserDto> pageData = new PageDataResponse <UserDto>(); var parameterExpression = System.Linq.Expressions.Expression.Parameter(typeof(User)); var filter = (System.Linq.Expressions.Expression)System.Linq.Expressions.Expression.Constant(true); if (!string.IsNullOrEmpty(pageParams.Key)) { pageParams.Key = pageParams.Key.Trim(); filter = (System.Linq.Expressions.Expression)System.Linq.Expressions.Expression.Constant(false); Guid guid = Guid.Empty; if (Guid.TryParse(pageParams.Key, out guid)) { filter = filter.GotoOrElse(parameterExpression.GotoEqual("ID", guid)); } } else { filter = filter.GotoOrElse(parameterExpression.GotoNotEqual("ID", Guid.Empty)); } if (pageParams.BeginTime != null && pageParams.EndTime != null && pageParams.BeginTime <= pageParams.EndTime) { filter = filter.GotoAndAlso(parameterExpression.GotoGreaterThanByDateTime("CreateTime", pageParams.BeginTime)); filter = filter.GotoAndAlso(parameterExpression.GotoLessThanByDateTime("CreateTime", pageParams.EndTime)); } filter = filter.GotoAndAlso(parameterExpression.GotoNotEqual("ID", ConstDefine.SuperAdminID)); var queryLambdaFilter = System.Linq.Expressions.Expression.Lambda <Func <User, bool> >(filter, parameterExpression); int Count; List <UserDto> List = _UserAppService.PageList(queryLambdaFilter, pageParams.PageSize, pageParams.CurPage, out Count); if (List.Any()) { var depIds = List.Select(a => a.DepartmentId).ToArray(); var depList = _departmentAppService.QueryList(c => depIds.Contains(c.ID)); foreach (var item in List) { var temp = depList.FirstOrDefault(a => a.ID == item.DepartmentId); if (temp != null) { item.DepartmentName = temp.Name; } } } pageData.Data = List; pageData.TotalItem = Count; pageData.QueryData = pageParams; pageData.PageHTML = base.PageHtml(Count, pageParams.CurPage, pageParams.PageSize, this.HttpContext); return(View(pageData)); }
public IActionResult GetTreeData() { var dtos = _service.QueryList(a => a.Name != ""); List <TreeModel> treeModels = new List <TreeModel>(); foreach (var dto in dtos) { treeModels.Add(new TreeModel() { Id = dto.ID.ToString(), Text = dto.Name, Parent = dto.ParentId == Guid.Empty ? "#" : dto.ParentId.ToString() }); } return(Json(treeModels)); }