Example #1
0
 public ViewResult Index(Cart cart, string returnUrl)
 {
     return View(new CartIndexViewModel
     {
         Cart = cart,
         ReturnUrl = returnUrl
     });
 }
Example #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 });
        }
Example #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;
        }
Example #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);
            }
        }
Example #5
0
 private Cart GetCart()
 {
     Cart cart = (Cart)Session["Cart"];
     if (cart == null)
     {
         cart = new Cart();
         Session["Cart"] = cart;
     }
     return cart;
 }
Example #6
0
 public PartialViewResult Summary(Cart cart)
 {
     return PartialView(cart);
 }