source: StockMaster/Views/User/Index.cshtml@ dfe03b8

main
Last change on this file since dfe03b8 was dfe03b8, checked in by Ceyda <ceyda.huseini@…>, 3 days ago

Initialize StockMaster project

  • Property mode set to 100644
File size: 4.1 KB
Line 
1@model List<StockMaster.Models.User>
2@{
3 ViewData["Title"] = "Users";
4}
5
6<div class="row mb-4">
7 <div class="col-md-6">
8 <h2><i class="fas fa-user-cog"></i> User Management</h2>
9 </div>
10 <div class="col-md-6 text-end">
11 <a href="/User/Create" class="btn btn-primary">
12 <i class="fas fa-plus"></i> Add New User
13 </a>
14 </div>
15</div>
16
17<div class="card">
18 <div class="card-header">
19 <i class="fas fa-list"></i> User List
20 </div>
21 <div class="card-body">
22 <div class="mb-3">
23 <input type="text" class="form-control" placeholder="Search users..." id="searchBox">
24 </div>
25
26 <div class="table-responsive">
27 <table class="table table-hover" id="usersTable">
28 <thead>
29 <tr>
30 <th>ID</th>
31 <th>Username</th>
32 <th>Full Name</th>
33 <th>Email</th>
34 <th>Role</th>
35 <th>Status</th>
36 <th>Created Date</th>
37 <th>Actions</th>
38 </tr>
39 </thead>
40 <tbody>
41 @foreach (var user in Model)
42 {
43 <tr>
44 <td>@user.UserId</td>
45 <td><strong>@user.Username</strong></td>
46 <td>@user.FullName</td>
47 <td>@user.Email</td>
48 <td>
49 <span class="badge bg-info">@user.Role</span>
50 </td>
51 <td>
52 @if (user.IsActive)
53 {
54 <span class="badge bg-success">
55 <i class="fas fa-check"></i> Active
56 </span>
57 }
58 else
59 {
60 <span class="badge bg-secondary">Inactive</span>
61 }
62 </td>
63 <td>@user.CreatedAt.ToString("dd.MM.yyyy")</td>
64 <td>
65 <div class="btn-group btn-group-sm">
66 <a href="/User/Edit/@user.UserId" class="btn btn-warning">
67 <i class="fas fa-edit"></i>
68 </a>
69 <button onclick="deleteUser(@user.UserId)" class="btn btn-danger">
70 <i class="fas fa-trash"></i>
71 </button>
72 </div>
73 </td>
74 </tr>
75 }
76 </tbody>
77 </table>
78 </div>
79
80 @if (!Model.Any())
81 {
82 <div class="text-center py-5">
83 <i class="fas fa-inbox fa-3x text-muted mb-3"></i>
84 <p class="text-muted">No users found.</p>
85 <a href="/User/Create" class="btn btn-primary">
86 <i class="fas fa-plus"></i> Add First User
87 </a>
88 </div>
89 }
90 </div>
91</div>
92
93@section Scripts {
94 <script>
95 function deleteUser(id) {
96 if (confirm('Are you sure you want to delete this user?')) {
97 const form = document.createElement('form');
98 form.method = 'POST';
99 form.action = '/User/Delete/' + id;
100 document.body.appendChild(form);
101 form.submit();
102 }
103 }
104
105 $(document).ready(function() {
106 $('#searchBox').on('keyup', function() {
107 const value = $(this).val().toLowerCase();
108 $('#usersTable tbody tr').filter(function() {
109 $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
110 });
111 });
112 });
113 </script>
114}
Note: See TracBrowser for help on using the repository browser.