add edit users for admin

This commit is contained in:
2024-08-10 17:10:45 +03:30
parent f71b11c131
commit 4ffc4197aa
15 changed files with 116 additions and 25 deletions

View File

@ -34,7 +34,7 @@
</td>
<td>
@Html.ActionLink("Read", "../news/Details", new { id = item.ID })|
@if (ViewBag.role == 1 || ViewBag.uid == item.userID)
@if (ViewBag.role > 0 || ViewBag.uid == item.userID)
{
@Html.ActionLink("Edit", "../news/Edit", new { id = item.ID })

View File

@ -31,7 +31,7 @@
<td>
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@if (ViewBag.role == 1)
@if (ViewBag.role > 0)
{
@Html.ActionLink("Edit", "Edit", new { id = item.ID })
<span>|</span>

View File

@ -59,7 +59,7 @@
<td>
@Html.ActionLink("Read", "Details", new { id = item.NewsID })|
@if (ViewBag.role == 1 || ViewBag.uid == item.userID)
@if (ViewBag.role > 0 || ViewBag.uid == item.userID)
{
@Html.ActionLink("Edit", "Edit", new { id = item.NewsID })

View File

@ -42,9 +42,7 @@
@Html.DisplayFor(modelItem => item.views)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
@Html.ActionLink("Details", "Details", new { id = item.ID })
</td>
</tr>
}

View File

@ -34,7 +34,7 @@
</td>
<td>
@Html.ActionLink("Read", "../news/Details", new { id = item.ID })|
@if (ViewBag.role == 1 || ViewBag.uid == item.userID)
@if (ViewBag.role > 0 || ViewBag.uid == item.userID)
{
@Html.ActionLink("Edit", "../news/Edit", new { id = item.ID })

View File

@ -30,7 +30,7 @@
</td>
<td>
@Html.ActionLink("Details", "Details", new { id = item.code }) |
@if (ViewBag.role == 1)
@if (ViewBag.role > 0)
{
@Html.ActionLink("Edit", "Edit", new { id = item.code })
<span>|</span>

View File

@ -27,7 +27,7 @@
<div class="form-group">
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="password", name="password" , class="form-control"/>
<input type="password" name="password" class="form-control"/>
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
</div>
</div>

View File

@ -0,0 +1,49 @@
@model WebApplication1.Models.user
@{
ViewBag.Title = "Edituser";
}
<h2>Edituser</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>user</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ID)
<div class="form-group">
@Html.LabelFor(model => model.displayname, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.displayname, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.displayname, "", new { @class = "text-danger" })
</div>
</div>
<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>
@Html.ValidationMessageFor(model => model.role, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>

View File

@ -14,9 +14,6 @@
<th>
@Html.DisplayNameFor(model => model.usename)
</th>
<th>
@Html.DisplayNameFor(model => model.password)
</th>
<th>
@Html.DisplayNameFor(model => model.displayname)
</th>
@ -28,9 +25,6 @@
<td>
@Html.DisplayFor(modelItem => item.usename)
</td>
<td>
@Html.DisplayFor(modelItem => item.password)
</td>
<td>
@Html.DisplayFor(modelItem => item.displayname)
</td>