Пример #1
0
 public ActionResult Index(Cart cart, string returnUrl)
 {
     return View(new CartIndexViewModel
     {
         //Cart = GetCart(),
         Cart = cart,
         ReturnUrl = returnUrl
     });
 }
Пример #2
0
 //从购物车移除
 public RedirectToRouteResult RemoveFromCart(Cart cart, int Id, string returnUrl)
 {
     Product product = ProductService.LoadEntities(p => p.Id == Id).FirstOrDefault();
     if (product != null)
     {
         //GetCart().RemoveLine(product);
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new {returnUrl});
 }
Пример #3
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     Cart cart = (Cart)controllerContext.HttpContext.Session[sessionKey];
     if (cart == null)
     {
         cart = new Cart();
         controllerContext.HttpContext.Session[sessionKey] = cart;
     }
     return cart;
 }
Пример #4
0
 public ViewResult CheckOut(Cart cart, ShippingDetail shippingDetail)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("","购物车为空");
     }
     if (ModelState.IsValid)
     {
         OrderProcessor.ProcessOrder(cart, shippingDetail);
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(shippingDetail);
     }
 }
Пример #5
0
 private Cart GetCart()
 {
     Cart cart = (Cart)Session["Cart"];
     if (cart == null)
     {
         cart = new Cart();
         Session["Cart"] = cart;
     }
     return cart;
 }
Пример #6
0
 public ViewResult Summary(Cart cart)
 {
     return View(cart);
 }