Ejemplo n.º 1
0
        public PagedResultList <RoleContract> GetRoleList(int?start, int?count, string filterByName)
        {
            var startValue = PagingHelper.GetStart(start);
            var countValue = PagingHelper.GetCount(count);

            var client = m_communicationProvider.GetAuthRoleApiClient();

            var authResult = client.GetRoleListAsync(startValue, countValue, filterByName).GetAwaiter().GetResult();

            var resultList = new List <RoleContract>();

            foreach (var authRoleContract in authResult.Items)
            {
                var synchronizeRoleWork = new SynchronizeRoleWork(m_permissionRepository, m_communicationProvider, authRoleContract);
                synchronizeRoleWork.Execute();

                var resultRoleContract = m_mapper.Map <RoleContract>(authRoleContract);
                resultRoleContract.Id = synchronizeRoleWork.LocalId;

                resultList.Add(resultRoleContract);
            }

            return(new PagedResultList <RoleContract>
            {
                List = resultList,
                TotalCount = authResult.ItemsCount,
            });
        }
Ejemplo n.º 2
0
        public PagedResultList <UserGroupContract> GetUserGroupsByProject(long projectId, int?start, int?count, string filterByName)
        {
            var startValue = PagingHelper.GetStart(start);
            var countValue = PagingHelper.GetCount(count);

            var result = m_permissionRepository.InvokeUnitOfWork(x => x.FindGroupsByBook(projectId, startValue, countValue, filterByName, true));

            if (result == null)
            {
                return(null);
            }

            var resultRoles = new List <UserGroupContract>();

            foreach (var group in result.List)
            {
                if (group is RoleUserGroup roleUserGroup)
                {
                    var work = new SynchronizeRoleWork(m_permissionRepository, m_communicationProvider, roleUserGroup.ExternalId);
                    work.Execute();
                    var authRoleContract = work.GetRoleContract();

                    var roleContract = m_mapper.Map <UserGroupContract>(authRoleContract);
                    roleContract.Id = group.Id;

                    resultRoles.Add(roleContract);
                }
                else
                {
                    var roleContract = m_mapper.Map <UserGroupContract>(group);
                    resultRoles.Add(roleContract);
                }
            }

            return(new PagedResultList <UserGroupContract>
            {
                List = resultRoles,
                TotalCount = result.Count,
            });
        }