add access level

This commit is contained in:
2024-08-12 17:15:11 +03:30
parent d123ce205f
commit 4380d9da5c
7 changed files with 103 additions and 37 deletions

View File

@ -2,6 +2,8 @@
@{
ViewBag.Title = "Edituser";
var allRoles = "addNews ,newsManagement, userManagment, tag&catManagment".Split(',');
var Roles = Model.role.Split(',');
}
<h2>Edituser</h2>
@ -9,7 +11,7 @@
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>user</h4>
<hr />
@ -28,10 +30,17 @@
<div class="form-group">
@Html.LabelFor(model => model.role, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<select name="role" class="form-control">
<option value="0">User</option>
<option value="2">Admin</option>
</select>
@foreach (var r in Roles) { @r}
@for (int i = 0; i < allRoles.Length; i++)
{
var r = allRoles[i];
<div class="form-check">
<input class="form-check-input" type="checkbox" value="@r" name="roles" id="flexCheckDefault_@i" @(Roles.Contains(r) ? "checked" : "")>
<label class="form-check-label" for="flexCheckDefault_@i">@r</label>
</div>
}
@Html.ValidationMessageFor(model => model.role, "", new { @class = "text-danger" })
</div>
</div>