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"); }
// // GET: /ShoppingCart/ public ActionResult Index() { if(Session["ShoppingCart"] == null) { Session["ShoppingCart"] = new ShoppingCart(); } ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart; return View(cart); }
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"); }