Skip to content

Commit

Permalink
Use UserManager to get users list
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-liu-toronto committed Jun 11, 2024
1 parent e9465e2 commit 623a736
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions IMS.WebApp/Components/Account/Pages/ManageUsers.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@page "/Account/ManageUsers"
@using IMS.WebApp.Data
@using Microsoft.AspNetCore.Identity

@attribute [Authorize(Policy = "Admin")]

@inject UserManager<ApplicationUser> UserManager

<h3>Manage Users</h3>
<br/>

@if (users is not null && users.Count > 0)
{
<table class="table">
<thead>
<tr>
<th>User</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(var user in users)
{
<tr>
<td>
@user.Email
</td>
<td>
<a href="/account/manageuser/@user.Id" class="btn btn-link">Manage</a>
</td>
</tr>
}
</tbody>
</table>
}

@code {
private List<ApplicationUser>? users;

protected override void OnInitialized()
{
base.OnInitialized();

users = UserManager.Users.ToList();
}

}
2 changes: 1 addition & 1 deletion IMS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IMS.Plugins", "IMS.Plugins"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IMS.Plugins.InMemory", "IMS.Plugins\IMS.Plugins.InMemory\IMS.Plugins.InMemory.csproj", "{292713AF-9940-4CF3-AA95-8AAE41E07A23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.Plugins.EFCoreSqlServer", "IMS.Plugins\IMS.Plugins.EFCoreSqlServer\IMS.Plugins.EFCoreSqlServer.csproj", "{44417527-BE6D-4A2C-9180-4775B15AB852}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IMS.Plugins.EFCoreSqlServer", "IMS.Plugins\IMS.Plugins.EFCoreSqlServer\IMS.Plugins.EFCoreSqlServer.csproj", "{44417527-BE6D-4A2C-9180-4775B15AB852}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit 623a736

Please sign in to comment.