コード例 #1
0
        public Task <PagedResultDto <UserDto> > GetAllOrSeach(string seachKey, string organzitionId, PagedAndSortedResultRequestDto input)
        {
            CheckGetAllPermission();

            if (!string.IsNullOrEmpty(seachKey))
            {
                var result = Repository.GetAll()
                             .Where(u => u.UserName.Contains(seachKey) || u.Name.Contains(seachKey) ||
                                    u.EName.Contains(seachKey) || u.SName.Contains(seachKey));
                var totalCount = result.Count();
                var query      = result.OrderByDescending(u => u.CreationTime).PageBy(input);
                var data       = new PagedResultDto <UserDto>(
                    totalCount,
                    query.AsEnumerable().Select(MapToEntityDto).ToList()
                    );
                return(Task.FromResult(data));
            }
            else
            {
                if (!string.IsNullOrEmpty(organzitionId))
                {
                    var result     = _organizationUnitManager.GetChildrenUsers(organzitionId);
                    var totalCount = result.Count();
                    var query      = result.OrderByDescending(u => u.CreationTime).PageBy(input);
                    var data       = new PagedResultDto <UserDto>(
                        totalCount,
                        query.AsEnumerable().Select(MapToEntityDto).ToList()
                        );
                    return(Task.FromResult(data));
                }
            }
            return(base.GetAll(input));
        }