예제 #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);
 }