コード例 #1
0
 public ActionResult Clear()
 {
     //We just clear the session when you clear the cart
     //Obviously not the smartest thing to do, but since the only thing the session saves is the cart, it works
     Session["ShoppingCart"] = new ShoppingCart();
     return RedirectToAction("Index");
 }
コード例 #2
0
 //
 // GET: /ShoppingCart/
 public ActionResult Index()
 {
     if(Session["ShoppingCart"] == null)
     {
         Session["ShoppingCart"] = new ShoppingCart();
     }
     ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart;
     return View(cart);
 }
コード例 #3
0
 public ActionResult AddToCart(int movID)
 {
     if (Session["ShoppingCart"] == null)
     {
         Session["ShoppingCart"] = new ShoppingCart();
     }
     ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart;
     cart.OrderLines.Add(new OrderLine(FakeDB.GetInstance().FindMovieByID(movID), 1));
     Session["ShoppingCart"] = cart;
     return RedirectToAction("Index");
 }