73 lines
No EOL
2.7 KiB
Text
73 lines
No EOL
2.7 KiB
Text
@model EditUserViewModel
|
|
|
|
@{
|
|
ViewData["Title"] = "Edit";
|
|
}
|
|
|
|
|
|
<div class="container mt-4">
|
|
<div class="card justify-content-center">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Edit user</h5>
|
|
|
|
<div class="row ">
|
|
<!-- 12 columns for textboxes -->
|
|
<form asp-action="Edit" method="post">
|
|
@Html.AntiForgeryToken()
|
|
|
|
<input type="hidden" asp-for="Id" />
|
|
|
|
<div class="form-group">
|
|
<label asp-for="FirstName"></label>
|
|
<input asp-for="FirstName" class="form-control" />
|
|
<span asp-validation-for="FirstName" class="text-danger"></span>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label asp-for="LastName"></label>
|
|
<input asp-for="LastName" class="form-control" />
|
|
<span asp-validation-for="LastName" class="text-danger"></span>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label asp-for="SelectedRoles">Roles</label>
|
|
<div>
|
|
@foreach (var role in Model.Roles)
|
|
{
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="SelectedRoles" value="@role.Value" id="@role.Value"
|
|
@(Model.SelectedRoles.Contains(role.Value) ? "checked='checked'" : "") />
|
|
<label class="form-check-label" for="@role.Value">@role.Text</label>
|
|
|
|
</div>
|
|
}
|
|
</div>
|
|
<button type="button" class="btn btn-secondary btn-sm" onclick="selectAllRoles(this)">Select All</button>
|
|
<span asp-validation-for="SelectedRoles" class="text-danger"></span>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<input type="submit" value="Save" class="btn btn-primary" />
|
|
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@section Scripts {
|
|
<script>
|
|
function selectAllRoles(button) {
|
|
var isChecked = button.textContent.includes("Select");
|
|
var checkboxes = document.querySelectorAll('.form-check-input');
|
|
checkboxes.forEach(checkbox => {
|
|
checkbox.checked = isChecked;
|
|
});
|
|
button.textContent = isChecked ? "Deselect All" : "Select All";
|
|
}
|
|
</script>
|
|
} |