public static async Task <User[]> GetAllAsync(this IGroupMembersCollectionWithReferencesRequest request)
        {
            var collectionPage = await request.GetAsync();

            return(await GetAllAsync(collectionPage)
                   .ContinueWith(i => i.Result.OfType <User>().ToArray()));
        }
        // GET group members and page through the results (10 at a time)
        public async Task <ActionResult> GroupMembers(string groupId, string nextLink)
        {
            // Show the profile of a user after a user is clicked from the search.
            var         client      = GetGraphServiceClient();
            List <User> userMembers = new List <User>();
            IGroupMembersCollectionWithReferencesPage    members        = new GroupMembersCollectionWithReferencesPage();
            IGroupMembersCollectionWithReferencesRequest membersRequest = null;

            try
            {
                if (groupId != null)
                {
                    var group = await client.Groups[groupId].Request().Select("displayName,id").GetAsync();
                    ViewBag.groupId   = groupId;
                    ViewBag.groupName = group.DisplayName;
                    membersRequest    = client.Groups[groupId].Members.Request().Top(10);
                }
                members = await membersRequest.GetAsync();

                foreach (DirectoryObject d in members.CurrentPage)
                {
                    User u = d as User;
                    userMembers.Add(u);
                }
            }
            catch (Exception)
            {
                // no users?
            }
            return(View(userMembers));
        }
Ejemplo n.º 3
0
        public static async Task <DirectoryObject[]> GetAllAsync(this IGroupMembersCollectionWithReferencesRequest request)
        {
            var collectionPage = await request.GetAsync();

            return(await GetAllAsync(collectionPage));
        }