public ActionResult AddToCart(int class_id, string semester_id) { var addedClass = db.Classes.Single(c => c.class_id == class_id && c.semster_id == semester_id); var cart = ShoppingCart.GetCart(this.HttpContext); cart.AddToCart(addedClass); var results = new ShoppingCartAlterViewModel { Message = Server.HtmlEncode(addedClass.course_id) + " has been added to your cart.", CartCount = cart.GetCount(), AlterId = class_id, AlterSemester = semester_id }; return Json(results); }
public ActionResult RemoveFromCart(int id) { var cart = ShoppingCart.GetCart(this.HttpContext); string course_id = db.Carts.Single(item => item.record_id == id).Class.course_id; cart.RemoveFromCart(id); var results = new ShoppingCartAlterViewModel { Message = Server.HtmlEncode(course_id) + " has been removed from your cart.", CartCount = cart.GetCount(), AlterId = id }; return Json(results); }