-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemberGroups.cshtml.cs
45 lines (39 loc) · 1.47 KB
/
MemberGroups.cshtml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using hack_together_groups_manager.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Graph;
namespace hack_together_groups_manager.Pages
{
public class MemberGroupsModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly GraphServiceClient _graphServiceClient;
public IEnumerable<Models.M365Group>? M365MemberGroups { get; set; }
public MemberGroupsModel(ILogger<IndexModel> logger, GraphServiceClient graphServiceClient)
{
_logger = logger;
_graphServiceClient = graphServiceClient;
}
public async Task OnGetAsync()
{
List<Models.M365Group> m365Groups = new();
var resultsMemberOf = await this._graphServiceClient.Me.MemberOf.Request().GetAsync();
foreach (var groupDirectoryObject in resultsMemberOf)
{
var group = groupDirectoryObject as Microsoft.Graph.Group;
if (group != null)
{
var groupInfo = new Models.M365Group
{
Id = group.Id,
DisplayName = group.DisplayName,
Description = group.Description,
Visibility = group.Visibility
};
m365Groups.Add(groupInfo);
}
}
M365MemberGroups = m365Groups;
}
}
}