| 1 | @model List<StockMaster.Models.Customer>
|
|---|
| 2 | @{
|
|---|
| 3 | ViewData["Title"] = "Customers";
|
|---|
| 4 | }
|
|---|
| 5 |
|
|---|
| 6 | <div class="row mb-4">
|
|---|
| 7 | <div class="col-md-6">
|
|---|
| 8 | <h2><i class="fas fa-users"></i> Customer Management</h2>
|
|---|
| 9 | </div>
|
|---|
| 10 | <div class="col-md-6 text-end">
|
|---|
| 11 | <a href="/Customer/Create" class="btn btn-primary">
|
|---|
| 12 | <i class="fas fa-plus"></i> Add New Customer
|
|---|
| 13 | </a>
|
|---|
| 14 | </div>
|
|---|
| 15 | </div>
|
|---|
| 16 |
|
|---|
| 17 | <div class="card">
|
|---|
| 18 | <div class="card-header">
|
|---|
| 19 | <i class="fas fa-list"></i> Customer List
|
|---|
| 20 | </div>
|
|---|
| 21 | <div class="card-body">
|
|---|
| 22 | <div class="mb-3">
|
|---|
| 23 | <input type="text" class="form-control" placeholder="Search customers..." id="searchBox">
|
|---|
| 24 | </div>
|
|---|
| 25 |
|
|---|
| 26 | <div class="table-responsive">
|
|---|
| 27 | <table class="table table-hover" id="customersTable">
|
|---|
| 28 | <thead>
|
|---|
| 29 | <tr>
|
|---|
| 30 | <th>ID</th>
|
|---|
| 31 | <th>Name</th>
|
|---|
| 32 | <th>Email</th>
|
|---|
| 33 | <th>Phone</th>
|
|---|
| 34 | <th>Address</th>
|
|---|
| 35 | <th>Created Date</th>
|
|---|
| 36 | <th>Actions</th>
|
|---|
| 37 | </tr>
|
|---|
| 38 | </thead>
|
|---|
| 39 | <tbody>
|
|---|
| 40 | @foreach (var customer in Model)
|
|---|
| 41 | {
|
|---|
| 42 | <tr>
|
|---|
| 43 | <td>@customer.CustomerId</td>
|
|---|
| 44 | <td><strong>@customer.Name</strong></td>
|
|---|
| 45 | <td>@customer.Email</td>
|
|---|
| 46 | <td>@customer.Phone</td>
|
|---|
| 47 | <td>@customer.Address</td>
|
|---|
| 48 | <td>@customer.CreatedAt.ToString("dd.MM.yyyy")</td>
|
|---|
| 49 | <td>
|
|---|
| 50 | <div class="btn-group btn-group-sm">
|
|---|
| 51 | <a href="/Customer/Edit/@customer.CustomerId" class="btn btn-warning">
|
|---|
| 52 | <i class="fas fa-edit"></i>
|
|---|
| 53 | </a>
|
|---|
| 54 | <button onclick="deleteCustomer(@customer.CustomerId)" class="btn btn-danger">
|
|---|
| 55 | <i class="fas fa-trash"></i>
|
|---|
| 56 | </button>
|
|---|
| 57 | </div>
|
|---|
| 58 | </td>
|
|---|
| 59 | </tr>
|
|---|
| 60 | }
|
|---|
| 61 | </tbody>
|
|---|
| 62 | </table>
|
|---|
| 63 | </div>
|
|---|
| 64 |
|
|---|
| 65 | @if (!Model.Any())
|
|---|
| 66 | {
|
|---|
| 67 | <div class="text-center py-5">
|
|---|
| 68 | <i class="fas fa-inbox fa-3x text-muted mb-3"></i>
|
|---|
| 69 | <p class="text-muted">No customers found.</p>
|
|---|
| 70 | <a href="/Customer/Create" class="btn btn-primary">
|
|---|
| 71 | <i class="fas fa-plus"></i> Add First Customer
|
|---|
| 72 | </a>
|
|---|
| 73 | </div>
|
|---|
| 74 | }
|
|---|
| 75 | </div>
|
|---|
| 76 | </div>
|
|---|
| 77 |
|
|---|
| 78 | @section Scripts {
|
|---|
| 79 | <script>
|
|---|
| 80 | function deleteCustomer(id) {
|
|---|
| 81 | if (confirm('Are you sure you want to delete this customer?')) {
|
|---|
| 82 | const form = document.createElement('form');
|
|---|
| 83 | form.method = 'POST';
|
|---|
| 84 | form.action = '/Customer/Delete/' + id;
|
|---|
| 85 | document.body.appendChild(form);
|
|---|
| 86 | form.submit();
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | $(document).ready(function() {
|
|---|
| 91 | $('#searchBox').on('keyup', function() {
|
|---|
| 92 | const value = $(this).val().toLowerCase();
|
|---|
| 93 | $('#customersTable tbody tr').filter(function() {
|
|---|
| 94 | $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
|
|---|
| 95 | });
|
|---|
| 96 | });
|
|---|
| 97 | });
|
|---|
| 98 | </script>
|
|---|
| 99 | } |
|---|