示例#1
0
        public Result <QueryOrganizationUserRoleResult> QueryOrganizationUserRole(QueryOrganizationUserRoleCriteria criteria)
        {
            HandlePaginationAndDirectionValidation(criteria);
            var result = organizationUserRoleRepository.QueryOrganizationUserRole(criteria);

            return(new Result <QueryOrganizationUserRoleResult>(result));
        }
示例#2
0
        public QueryOrganizationUserRoleResult QueryOrganizationUserRole(QueryOrganizationUserRoleCriteria criteria)
        {
            if (criteria.Page == null || criteria.PageSize == null)
            {
                return(null);
            }

            var pageSize  = criteria.PageSize.Value;
            var pageValue = criteria.Page.Value;

            IQueryable <OrganizationUserRoleEntity> queryable = this.context.OrganizationUserRoles;

            if (!string.IsNullOrEmpty(criteria.RoleId))
            {
                queryable = queryable.Where(our => our.RoleId.Equals(criteria.RoleId));
            }

            if (criteria.OrganizationUserId.HasValue)
            {
                queryable = queryable.Where(our => our.OrganizationUserId.Equals(criteria.OrganizationUserId));
            }

            if (criteria.OrganizationId.HasValue)
            {
                queryable = queryable.Where(our => our.OrganizationId.Equals(criteria.OrganizationId));
            }

            var count = queryable.Count();

            int page = (pageValue - 1) * pageSize;

            var views = queryable
                        .Skip(page)
                        .Take(pageSize)
                        .ToList();

            var results = views.Select(p => this.mapper.Map <OrganizationUserRoleListView>(p))
                          .ToList();


            return(new QueryOrganizationUserRoleResult
            {
                Pagination = new PaginationModel(count, pageValue, pageSize),
                Result = results
            });
        }