示例#1
0
 public ViewResult Index(Cart cart, string returnUrl)
 {
     return View(new CartIndexViewModel
     {
         Cart = cart,
         ReturnUrl = returnUrl
     });
 }
示例#2
0
        public RedirectToRouteResult RemoveFromCart(Cart cart, int songId, string returnUrl)
        {
            Song song = repository.Songs
                .FirstOrDefault(s => s.SongID == songId);

            if (song != null)
            {
                cart.RemoveLine(song);
            }

            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, CustomerDetails customerDetails)
        {
            if (cart.Lines.Count() == 0)
            {
                ModelState.AddModelError("", "Sorry your cart is empty!");
            }

            if (ModelState.IsValid)
            {
                cart.Clear();
                return View("Completed");
            }
            else
            {
                return View(customerDetails);
            }
        }
示例#5
0
 private Cart GetCart()
 {
     Cart cart = (Cart)Session["Cart"];
     if (cart == null)
     {
         cart = new Cart();
         Session["Cart"] = cart;
     }
     return cart;
 }
示例#6
0
 public PartialViewResult Summary(Cart cart)
 {
     return PartialView(cart);
 }