//[Authorize] public IActionResult Checkout() { var items = _shopingCart.GetShopingCartItems(); _shopingCart.ShopingCartItems = items; if (_shopingCart.ShopingCartItems.Count == 0) { ModelState.AddModelError("", "Cart is Empty. Add some Books first."); } CheckoutViewModel orderView = new CheckoutViewModel { ShopingCart = _shopingCart, ShopingCartTotal = _shopingCart.GetShopingCartTotal() }; return(View(orderView)); }
public IViewComponentResult Invoke() { _shopingCart.ShopingCartItems = _shopingCart.GetShopingCartItems(); //_shopingCart.ShopingCartItems = new List<ShopingCartItem> { new ShopingCartItem(), new ShopingCartItem() }; var shopingCartVM = new ViewModels.ShopingCartViewModel { ShopingCart = _shopingCart, ShopingCartTotal = _shopingCart.GetShopingCartTotal() }; return(View(shopingCartVM)); }
// GET: ShopingCart public ViewResult Index() { //Getting Shoping Cart Items var items = _shopingCart.GetShopingCartItems(); _shopingCart.ShopingCartItems = items; //Setting Shoping Cart View Model var shopingCartVM = new ShopingCartViewModel { ShopingCart = _shopingCart, ShopingCartTotal = _shopingCart.GetShopingCartTotal() }; return(View(shopingCartVM)); }
public IActionResult CheckOut(Order order) { var items = _shopingCart.GetShopingCartItems(); _shopingCart.ShopingCartItems = items; if (_shopingCart.ShopingCartItems.Count == 0) { ModelState.AddModelError("", "Cart is Empty. Add some Books first."); } if (ModelState.IsValid) { order.OrderedPlaced = DateTime.Now; order.OrderTotal = _shopingCart.GetShopingCartTotal(); _orderRepository.CreateOrder(order); _shopingCart.ClearCart(); return(RedirectToAction("CheckoutComplete")); } return(View()); }