public IViewComponentResult Invoke() { var items = _shoppingCart.GetShoppingCartItems(); _shoppingCart.ShoppingCartItems = items; var shoppingCartModel = new ShoppingCardModel { ShoppingCart = _shoppingCart, ShoppingCartTotal = _shoppingCart.GetShoppingCardTotal() }; return(View(shoppingCartModel)); }
public IActionResult Index() { var items = _shoppingCart.GetShoppingCartItems(); _shoppingCart.ShoppingCartItems = items; var model = new ShoppingCardModel { ShoppingCart = _shoppingCart, ShoppingCartTotal = _shoppingCart.GetShoppingCardTotal() }; return(View(model)); }
public IEnumerable <ShoppingCardModel> GetUserShoppingCard(int userID) { var shoppingCardDB = _UnitOfWork.ShoppingCard.GetByUserID(userID); List <ShoppingCardModel> lShoppingCardModel = new List <ShoppingCardModel>(); foreach (var item in shoppingCardDB) { ShoppingCardModel model = new ShoppingCardModel() { ID = item.ID, OrderID = (item.OrderID.HasValue) ? item.OrderID.Value : 0, UserID = item.UserID, ProductID = item.ProductID, Quantity = item.Quantity }; lShoppingCardModel.Add(model); } return(lShoppingCardModel); }