generated from egmont11/ASP.Net-Core-MVC-Template
Initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
@model UserWithRolesViewModel
|
||||
@{
|
||||
ViewData["Title"] = "User Details";
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<a asp-action="Index" class="btn btn-secondary">← Back to List</a>
|
||||
</div>
|
||||
|
||||
@if (TempData["SuccessMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-success">@TempData["SuccessMessage"]</div>
|
||||
}
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h3 class="card-title mb-0">User Information: @Model.UserEntity.UserName</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ID</dt>
|
||||
<dd class="col-sm-9">@Model.UserEntity.Id</dd>
|
||||
|
||||
<dt class="col-sm-3">Username</dt>
|
||||
<dd class="col-sm-9">@Model.UserEntity.UserName</dd>
|
||||
|
||||
<dt class="col-sm-3">Email</dt>
|
||||
<dd class="col-sm-9">@Model.UserEntity.Email</dd>
|
||||
|
||||
<dt class="col-sm-3">Roles</dt>
|
||||
<dd class="col-sm-9">
|
||||
@foreach (var role in Model.Roles)
|
||||
{
|
||||
<span class="badge @(role == "Admin" ? "bg-danger" : "bg-info")">@role</span>
|
||||
}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Edit Roles</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form asp-action="UpdateRoles" asp-route-id="@Model.UserEntity.Id" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="d-flex gap-4 flex-wrap mb-3">
|
||||
@foreach (var role in Model.AllRoles)
|
||||
{
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
name="selectedRoles" value="@role" id="role_@role"
|
||||
@(Model.Roles.Contains(role) ? "checked" : "") />
|
||||
<label class="form-check-label" for="role_@role">@role</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Roles</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,39 @@
|
||||
@model IEnumerable<UserWithRolesViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "User Management";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Users</h1>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Roles</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var vm in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@vm.UserEntity.Id</td>
|
||||
<td>@vm.UserEntity.UserName</td>
|
||||
<td>@vm.UserEntity.Email</td>
|
||||
<td>
|
||||
@foreach (var role in vm.Roles)
|
||||
{
|
||||
<span class="badge @(role == "Admin" ? "bg-danger" : "bg-info")">@role</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@vm.UserEntity.Id" class="btn btn-sm btn-outline-primary">Details</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in New Issue
Block a user