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

            var client = m_communicationProvider.GetAuthUserApiClient();

            var result = client.GetUserListAsync(startValue, countValue, filterByName).GetAwaiter().GetResult();
            var userDetailContracts = m_mapper.Map <List <UserDetailContract> >(result.Items);

            m_userDetailManager.AddIdForExternalUsers(userDetailContracts);

            return(new PagedResultList <UserDetailContract>
            {
                List = userDetailContracts,
                TotalCount = result.ItemsCount,
            });
        }
Ejemplo n.º 2
0
        public PagedResultList <UserContract> GetUsersByGroup(int groupId, int?start, int?count, string filterByName)
        {
            // Method required for Role management (select role, load users)

            var role = m_permissionRepository.InvokeUnitOfWork(x => x.FindById <UserGroup>(groupId));

            if (role is RoleUserGroup roleUserGroup)
            {
                // If UserGroup has relation to Roles on Auth service, use user list from Auth service (the main data source)

                var client = m_communicationProvider.GetAuthRoleApiClient();
                var result = client.GetUserListByRoleAsync(roleUserGroup.ExternalId, start, count, filterByName).GetAwaiter().GetResult();
                var users  = m_mapper.Map <List <UserContract> >(result.Items);
                m_userDetailManager.AddIdForExternalUsers(users);

                return(new PagedResultList <UserContract>
                {
                    List = users,
                    TotalCount = result.ItemsCount
                });
            }
            else
            {
                // If UserGroup has no relation to Auth service (permissions to books), use local user list

                var startValue = PagingHelper.GetStart(start);
                var countValue = PagingHelper.GetCount(count);
                var dbUsers    = m_userRepository.InvokeUnitOfWork(x => x.GetUsersByGroup(groupId, startValue, countValue, filterByName));

                var resultList = new List <UserContract>();
                foreach (var dbUser in dbUsers.List)
                {
                    var resultUser = m_mapper.Map <UserContract>(dbUser);
                    resultUser.FirstName = dbUser.ExtFirstName;
                    resultUser.LastName  = dbUser.ExtLastName;
                    resultUser.UserName  = dbUser.ExtUsername;
                    resultList.Add(resultUser);
                }

                return(new PagedResultList <UserContract>
                {
                    List = resultList,
                    TotalCount = dbUsers.Count,
                });
            }
        }