public IViewComponentResult Invoke() { var items = _shopingCardRepo.GetShopingCards(); _shopingCardRepo.ShopingCards = items; var shopingCardViewModel = new ShopingCardViewModel { ShopingCard = _shopingCardRepo, ShopingCardTotal = _shopingCardRepo.GetTotalShopingCards() }; return(View(shopingCardViewModel)); }
// GET: /<controller>/ public IActionResult Index() { var items = _shopingRepo.GetShopingCards(); _shopingRepo.ShopingCards = items; var shopingCardViewModel = new ShopingCardViewModel { ShopingCard = _shopingRepo, ShopingCardTotal = _shopingRepo.GetTotalShopingCards() }; return(View(shopingCardViewModel)); }
public IActionResult CheckOut(Order order) { var items = _shopingRepo.GetShopingCards(); _shopingRepo.ShopingCards = items; if (_shopingRepo.ShopingCards.Count == 0) { ModelState.AddModelError("", "Your card is empty, please add some products."); } if (ModelState.IsValid) { _orderRepo.CreateOrder(order); _shopingRepo.ClearCard(); return(RedirectToAction("CheckOutComplete")); } return(View(order)); }