public ActionResult CheckOut( [ModelBinder(typeof(ShoppingCartBinder))] ShoppingCart shoppingCart) { Order order = new Order { OrderID = Guid.NewGuid().ToString(), OrderTime = DateTime.Now, UserName = User.Identity.Name }; foreach (ShoppingCartItem item in shoppingCart.Items) { order.OrderLines.Add(new OrderLine { Order = order, OrderID = order.OrderID, ProductID = item.ProductId, Quantity = item.Quantity }); } this.orderService.SubmitOrder(order); ShoppingCartBinder.Clear(); return(View()); }
public ActionResult Remove(string productId) { ShoppingCart shoppingCart = ShoppingCartBinder.GetShoppingCart(); ShoppingCartItem cartItem = shoppingCart.Items.FirstOrDefault(item => item.ProductId == productId); if (null != cartItem) { shoppingCart.Items.Remove(cartItem); } return(RedirectToAction("ShoppingCart")); }
public ActionResult ShoppingCart(string productId, string productName, decimal price, [ModelBinder(typeof(ShoppingCartBinder))] ShoppingCart shoppingCart) { shoppingCart.Add(productId, productName, price); return(View(ShoppingCartBinder.GetShoppingCart())); }