SurveyVista/Web/Areas/Admin/Views/Users/Index.cshtml
2024-05-04 20:19:22 +02:00

64 lines
2.5 KiB
Text

@model IEnumerable<RegisterViewModel>
@{
ViewData["Title"] = "List of users";
}
<div class="container mt-5">
<partial name="_Notification" />
<div class="card bg-default mb-3">
<div class="card-header">Users</div>
<div class="card-body">
<p>
<a asp-action="Register" class="btn btn-primary">Register new user</a>
</p>
<h4 class="card-title">Users List</h4>
<form asp-action="DeleteSelected" method="post">
<table class="table table-responsive w-100 d-block d-md-table">
<thead class="w-100">
<tr>
<th><input type="checkbox" id="selectAll" onclick="toggleAll(this.checked)" /></th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Roles</th>
<th class="text-end">Action</th>
</tr>
</thead>
<tbody class="w-100">
@foreach (var item in Model)
{
<tr>
<td><input type="checkbox" name="selectedUserIds" value="@item.Email" /></td>
<td>@item.FirstName</td>
<td>@item.LastName</td>
<td>@item.Email</td>
<td class="text-primary font-weight-bold"> @string.Join(", ", item.SelectedRoles)</td>
<td class="text-end">
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-info btn-sm">Edit</a>
@* <a asp-action="Edit" asp-controller="Users" asp-route-id="@item.Id">Edit</a> *@
</td>
</tr>
}
</tbody>
</table>
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete the selected users?');">Delete Selected</button>
</form>
</div>
</div>
</div>
@section Scripts {
<script>
function toggleAll(isChecked) {
var checkboxes = document.querySelectorAll('input[name="selectedUserIds"]');
checkboxes.forEach(ch => ch.checked = isChecked);
}
</script>
}