Skip to content

Commit

Permalink
Added group details
Browse files Browse the repository at this point in the history
  • Loading branch information
SmitaNachan committed Mar 12, 2023
1 parent 6835795 commit 1c03031
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 16 deletions.
7 changes: 3 additions & 4 deletions Models/M365Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ public class M365Group
public string? DisplayName { get; set; }
public string? Description { get; set; }
public string? Visibility { get; set; }
public string? Url { get; set; }
public string? Thumbnail { get; set; }
public string? UserRole { get; set; }
public bool TeamsConnected { get; set; }

public List<string>? Owners { get; set; }
public List<string>? Members { get; set; }
}
}
54 changes: 54 additions & 0 deletions Pages/GroupDetails.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
@page
@model hack_together_groups_manager.Pages.GroupDetailsModel
@{
ViewData["Title"] = "M365 Group Details";
}

<style>
body {
padding: 20px 0;
background: #f2f5f8;
}
</style>

<div class="text-left">
<h3 class="display-8">Group Details: </h3>

<table>
<tr>
<td>Display Name:</td>
<td>@Model.M365GroupDetails.DisplayName</td>
</tr>
<tr>
<td>Description:</td>
<td>@Model.M365GroupDetails.Description</td>
</tr>
<tr>
<td>Visibility:</td>
<td>@Model.M365GroupDetails.Visibility</td>
</tr>
</table>

<p></p>
<div>Owners:</div>
<table class="table table-striped border">
@foreach (var owner in Model.M365GroupDetails.Owners)
{
<tr>
<td>
@Html.DisplayFor(m => owner)
</td>
</tr>
}
</table>

<p></p>
<div>Members:</div>
<table class="table table-striped border">
@foreach (var member in Model.M365GroupDetails.Members)
{
<tr>
<td>
@Html.DisplayFor(m => member)
</td>
</tr>
}
</table>
</div>

52 changes: 51 additions & 1 deletion Pages/GroupDetails.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Graph;
using System.Diagnostics.Metrics;

namespace hack_together_groups_manager.Pages
{
public class GroupDetailsModel : PageModel
{
public void OnGet()
private readonly ILogger<IndexModel> _logger;
private readonly GraphServiceClient _graphServiceClient;
public Models.M365Group M365GroupDetails { get; set; }

public GroupDetailsModel(ILogger<IndexModel> logger, GraphServiceClient graphServiceClient)
{
_logger = logger;
_graphServiceClient = graphServiceClient;
}

public async Task OnGetAsync()
{
string groupId = HttpContext.Request.Query["groupId"];
var groupInfo = new Models.M365Group();

if (groupId != null)
{
var resultGroupInfo = await this._graphServiceClient.Groups[groupId].Request().GetAsync();
if (resultGroupInfo != null)
{
var group = resultGroupInfo as Microsoft.Graph.Group;

groupInfo.Description = group.Description;
groupInfo.DisplayName = group.DisplayName;
groupInfo.Visibility = group.Visibility;
}

var resultMembersInfo = await this._graphServiceClient.Groups[groupId].Members.Request().GetAsync();
if (resultMembersInfo != null)
{
groupInfo.Members = new List<string>();
foreach (var member in resultMembersInfo)
{
groupInfo.Members.Add((member as Microsoft.Graph.User).UserPrincipalName);
}
}

var resultOwnersInfo = await this._graphServiceClient.Groups[groupId].Owners.Request().GetAsync();
if (resultOwnersInfo != null)
{
groupInfo.Owners = new List<string>();
foreach (var owner in resultOwnersInfo)
{
groupInfo.Owners.Add((owner as Microsoft.Graph.User).UserPrincipalName);
}
}
}

M365GroupDetails = groupInfo;
}
}
}
2 changes: 1 addition & 1 deletion Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
<tr>
<td>
@Html.DisplayFor(m => item.DisplayName)
<a href="/GroupDetails?groupId=@Html.DisplayFor(m => item.Id)">@Html.DisplayFor(m => item.DisplayName)</a>
</td>
<td>
@Html.DisplayFor(m => item.Description)
Expand Down
9 changes: 0 additions & 9 deletions Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,5 @@ public async Task OnGetAsync()

M365Groups = m365Groups;
}
public ActionResult GroupDetails(string Id)
{
return RedirectToAction("GroupDetails");
}

public ActionResult Edit(string Id)
{
return RedirectToAction("GroupDetails");
}
}
}
2 changes: 1 addition & 1 deletion Pages/MemberGroups.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{
<tr>
<td>
@Html.DisplayFor(m => item.DisplayName)
<a href="/GroupDetails?groupId=@Html.DisplayFor(m => item.Id)">@Html.DisplayFor(m => item.DisplayName)</a>
</td>
<td>
@Html.DisplayFor(m => item.Description)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Member Groups page showing the M365 groups, an user is member of:

![Member Groups](./assets/member-groups.png)

Clicking the Group name will display additional information of the Group.

![Group Details](./assets/group-details.png)

## Minimal path to awesome

Follow below steps to use this app:
Expand Down
Binary file added assets/group-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/member-groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/owned-groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1c03031

Please sign in to comment.