public ActionResult AddToCart(int id) { var pr = db.Products.Single(p => p.ProductID == id); //ViewData["student"] = db.Products.Find(id); var cart = PCShopCart.GetCart(HttpContext); cart.AddToCart(pr); return(RedirectToAction("Index", pr)); }
// GET: PCShopCart public ActionResult Index() { var cart = PCShopCart.GetCart(HttpContext); var vm = new PCShopCartVM { CartItems = cart.GetCartItems(), CartSaldo = cart.GetTotal() }; return(View(vm)); }
public ActionResult RemoveFromCart(int id) { var cart = PCShopCart.GetCart(HttpContext); int count = cart.RemoveFromCart(id); var result = new PCShopCartRemoveVM { CartSaldo = cart.GetTotal(), CartCount = cart.GetCount(), RemoveID = id }; return(RedirectToAction("Index")); }
// GET: Buy public ActionResult Buy() { { if (Session["LogedID"] != null) { int id; id = Convert.ToInt32(Session["id"]); Customer user = db.Customers.Find(id); var cart = PCShopCart.GetCart(HttpContext); cart.CreateOrder(user); return(View("Buy")); } else { return(View("NoBuy")); } } }