Skip to content

Commit

Permalink
[Added] view permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nobir committed Jul 20, 2022
1 parent fdfb7c1 commit 40ce555
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ public ActionResult Index()
return View();
}

public ActionResult ViewPermissions(int? id)
{
int perpage = 5;
int currentpage = id ?? 1;
var _permissions = this.db.Permissions.ToList();

var permissions = _permissions.Skip((currentpage - 1) * perpage).Take(perpage).ToList();
int maxpage = (int)Math.Ceiling(Convert.ToDouble(_permissions.Count()) / Convert.ToDouble(perpage));

ViewBag.Permissions = permissions;

if (currentpage < maxpage)
{
ViewBag.NextPageUrl = Url.Action("ViewPermissions", new { id = currentpage + 1 });
}

if (1 < currentpage)
{
ViewBag.PreviousPageUrl = Url.Action("ViewPermissions", new { id = currentpage - 1 });
}

return View();
}

[HttpGet]
public ActionResult CreatePermission()
{
Expand Down
1 change: 1 addition & 0 deletions ERPSystemTimologio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
<Content Include="Views\Dashboard\ProfilePicture.cshtml" />
<Content Include="Views\Admin\CreatePermission.cshtml" />
<Content Include="Views\Admin\EditPermission.cshtml" />
<Content Include="Views\Admin\ViewPermissions.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
Expand Down
53 changes: 53 additions & 0 deletions Views/Admin/ViewPermissions.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

@{
ViewBag.Title = "ViewPermission";
}
<div class="table-responsive w-100">
<table class="table table-success table-striped min-width-400px">
<thead class="table-dark">
<tr>
<th>Name</th>
<th>Permissions</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (ERPSystemTimologio.EF.Permission permission in ViewBag.Permissions)
{
<tr>
<td>@permission.Name</td>
<td>
@(permission.InvoiceAdd == 1 ? "Invoice Add, " : "")
@(permission.InvoiceManage == 1 ? "Invoice Manage, " : "")
@(permission.InventoryManage == 1 ? "Inventory Manage, " : "")
@(permission.CategoryManage == 1 ? "Category Manage, " : "")
@(permission.StationManage == 1 ? "Region/Branch Manage, " : "")
@(permission.OperationManage == 1 ? "Operation Manage, " : "")
@(permission.UserManage == 1 ? "User Manage, " : "")
@(permission.PermissionManage == 1 ? "Permission Manage, " : "")
</td>
<td>
<a href="@Url.Action("EditPermission", new { id = permission.Id })"
class="btn btn-primary">Edit</a>
<a href="@Url.Action("DeletePermission", new { id = permission.Id })" id="delete-btn"
class="btn btn-danger delete-btn">Delete</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="d-flex justify-content-center align-items-center mt-4">
<nav aria-label="Page navigation example">
<ul class="pagination">
@if (ViewBag.PreviousPageUrl != null)
{
<li class="page-item"><a class="page-link" href="@ViewBag.PreviousPageUrl">Previous</a></li>
}
@if (ViewBag.NextPageUrl != null)
{
<li class="page-item"><a class="page-link" href="@ViewBag.NextPageUrl">Next</a></li>
}
</ul>
</nav>
</div>

0 comments on commit 40ce555

Please sign in to comment.