Skip to content

Commit

Permalink
Section 11 - OrderVM and Retrieve all Orders
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 26, 2021
1 parent cd232c6 commit cc33b1d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
14 changes: 14 additions & 0 deletions BulkyBook.Models/ViewModels/OrderVM.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BulkyBook.Models.ViewModels
{
public class OrderVM
{
public OrderHeader OrderHeader { get; set; }
public IEnumerable<OrderDetail> OrderDetail { get; set; }
}
}
31 changes: 31 additions & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using BulkyBook.DataAccess.Repository.IRepository;
using BulkyBook.Models;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace BulkyBookWeb.Areas.Admin.Controllers
{
public class OrderController : Controller
{
private readonly IUnitOfWork _unitOfWork;
public OrderController(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}

public IActionResult Index()
{
return View();
}

#region API CALLS
[HttpGet]
public IActionResult GetAll()
{
IEnumerable<OrderHeader> orderHeaders;
orderHeaders = _unitOfWork.OrderHeader.GetAll(includeProperties: "ApplicationUser");
return Json(new { data = orderHeaders });
}
#endregion
}
}
5 changes: 5 additions & 0 deletions BulkyBookWeb/Areas/Admin/Views/Order/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
4 changes: 0 additions & 4 deletions BulkyBookWeb/Areas/Customer/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ public IActionResult SummaryPOST()
{
return RedirectToAction("OrderConfirmation", "Cart", new { id = ShoppingCartVM.OrderHeader.Id });
}

//_unitOfWork.ShoppingCart.RemoveRange(ShoppingCartVM.ListCart);
//_unitOfWork.Save();
//return RedirectToAction("Index","Home");
}

public IActionResult OrderConfirmation(int id)
Expand Down

0 comments on commit cc33b1d

Please sign in to comment.