Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit f9e5ec9

Browse files
author
Jim Crowley
committed
fixing get owners and get members
1 parent 63c056e commit f9e5ec9

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

Microsoft-Graph-Snippets-SDK/Groups/GroupSnippets.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,16 @@ public static async Task<IGroupMembersCollectionWithReferencesPage> GetGroupMemb
7878

7979
try
8080
{
81-
var group = await graphClient.Groups[groupId].Request().GetAsync();
81+
var group = await graphClient.Groups[groupId].Request().Expand("members").GetAsync();
8282
members = group.Members;
8383

84-
//Work around the fact that some groups don't have owners.
85-
//Return a non-null collection whenever the call has worked
86-
//but the group has no owners.
87-
if (members != null)
84+
85+
foreach (var member in members)
8886
{
89-
foreach (var member in members)
90-
{
91-
Debug.WriteLine("Member Id:" + member.Id);
87+
Debug.WriteLine("Member Id:" + member.Id);
9288

93-
}
9489
}
9590

96-
else
97-
{
98-
members = new GroupMembersCollectionWithReferencesPage();
99-
}
10091
}
10192

10293
catch (ServiceException e)
@@ -117,24 +108,13 @@ public static async Task<IGroupOwnersCollectionWithReferencesPage> GetGroupOwner
117108
try
118109
{
119110

120-
var group = await graphClient.Groups[groupId].Request().GetAsync();
111+
var group = await graphClient.Groups[groupId].Request().Expand("owners").GetAsync();
121112
owners = group.Owners;
122113

123-
124-
//Work around the fact that some groups don't have owners.
125-
//Return a non-null collection whenever the call has worked
126-
//but the group has no owners.
127-
if (owners != null)
114+
foreach (var owner in owners)
128115
{
129-
foreach (var owner in owners)
130-
{
131-
Debug.WriteLine("Owner Id:" + owner.Id);
132-
}
116+
Debug.WriteLine("Owner Id:" + owner.Id);
133117
}
134-
else
135-
{
136-
owners = new GroupOwnersCollectionWithReferencesPage();
137-
}
138118

139119
}
140120

0 commit comments

Comments
 (0)