Skip to content

Commit

Permalink
Section 11 - Display all Orders
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 26, 2021
1 parent cc33b1d commit 69cd29d
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 75 deletions.
1 change: 1 addition & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace BulkyBookWeb.Areas.Admin.Controllers
{
[Area("Admin")]
public class OrderController : Controller
{
private readonly IUnitOfWork _unitOfWork;
Expand Down
33 changes: 28 additions & 5 deletions BulkyBookWeb/Areas/Admin/Views/Order/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<div class="container p-3">
<div class="row pt-4">
<div class="col-6">
<h2 class="text-primary">Order List</h2>
</div>
<div class="col-6 text-end">
</div>
</div>
<br /><br />

<table id="tblData" class="table table-bordered table-striped" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Phone Number</th>
<th>Email</th>
<th>Status</th>
<th>Total</th>
<th></th>
</tr>
</thead>
</table>
</div>

@section Scripts{
<script src="~/js/order.js"></script>
}
140 changes: 70 additions & 70 deletions BulkyBookWeb/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - BulkyBookWeb</title>
<link rel="stylesheet" href="~/css/bootswatchTheme.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.11.2/css/jquery.dataTables.min.css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - BulkyBookWeb</title>
<link rel="stylesheet" href="~/css/bootswatchTheme.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.11.2/css/jquery.dataTables.min.css" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor02">
<ul class="navbar-nav me-auto">
<li class="nav-item">

<div class="collapse navbar-collapse" id="navbarColor02">
<ul class="navbar-nav me-auto">
<li class="nav-item">

<a class="nav-link " asp-area="Customer" asp-controller="Home" asp-action="Index">Home</a>



<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Content Managment</a>
<div class="dropdown-menu">
<a class="dropdown-item" asp-area="Admin" asp-controller="Category" asp-action="Index">Category</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="CoverType" asp-action="Index">Cover Type</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="Product" asp-action="Index">Product</a>

<div class="dropdown-divider"></div>
<a class="dropdown-item" asp-area="Admin" asp-controller="Company" asp-action="Index">Company</a>

</div>
</li>
<li class="nav-item">
<a class=nav-link asp-area="Customer" asp-controller="Cart" asp-action="Index">
<i class="bi bi-cart"></i>
</a>
</li>
</ul>
<partial name="_LoginPartial" />
@* <form class="d-flex">
<input class="form-control me-sm-2" type="text" placeholder="Search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>*@
</div>
</div>
</nav>

</header>
<div class="container">
<main role="main" class="pb-3">
<partial name="_Notification" />
@RenderBody()
</main>
</div>
<a class="nav-link " asp-area="Customer" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Content Managment</a>
<div class="dropdown-menu">
<a class="dropdown-item" asp-area="Admin" asp-controller="Category" asp-action="Index">Category</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="CoverType" asp-action="Index">Cover Type</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="Product" asp-action="Index">Product</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" asp-area="Admin" asp-controller="Company" asp-action="Index">Company</a>
</div>
</li>
<li class="nav-item">
<a class=nav-link asp-area="Admin" asp-controller="Order" asp-action="Index">
Manage Order
</a>
</li>
<li class="nav-item">
<a class=nav-link asp-area="Customer" asp-controller="Cart" asp-action="Index">
<i class="bi bi-cart"></i>
</a>
</li>
</ul>
<partial name="_LoginPartial" />
@* <form class="d-flex">
<input class="form-control me-sm-2" type="text" placeholder="Search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>*@
</div>
</div>
</nav>

<footer class="footer text-muted bg-primary">
<div class="container">
&copy; 2021 - BulkyBookWeb
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="//cdn.datatables.net/1.11.2/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script src="https://cdn.tiny.cloud/1/n94ifuzvl80pchikopiwgz2esrw8n28dwcywvpejlqrregfp/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
@await RenderSectionAsync("Scripts", required: false)
</header>
<div class="container">
<main role="main" class="pb-3">
<partial name="_Notification" />
@RenderBody()
</main>
</div>

<footer class="footer text-muted bg-primary">
<div class="container">
&copy; 2021 - BulkyBookWeb
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="//cdn.datatables.net/1.11.2/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script src="https://cdn.tiny.cloud/1/n94ifuzvl80pchikopiwgz2esrw8n28dwcywvpejlqrregfp/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
34 changes: 34 additions & 0 deletions BulkyBookWeb/wwwroot/js/order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var dataTable;

$(document).ready(function () {
loadDataTable();
});

function loadDataTable() {
dataTable = $('#tblData').DataTable({
"ajax": {
"url":"/Admin/Order/GetAll"
},
"columns": [
{ "data": "id", "width": "5%" },
{ "data": "name", "width": "25%" },
{ "data": "phoneNumber", "width": "15%" },
{ "data": "applicationUser.email", "width": "15%" },
{ "data": "orderStatus", "width": "15%" },
{ "data": "orderTotal", "width": "10%" },
{
"data": "id",
"render": function (data) {
return `
<div class="w-75 btn-group" role="group">
<a href="/Admin/Order/Details?orderId=${data}"
class="btn btn-primary mx-2"> <i class="bi bi-pencil-square"></i></a>
</div>
`
},
"width": "5%"
}
]
});
}

0 comments on commit 69cd29d

Please sign in to comment.