public ActionResult CartReHeader()
        {
            var cart = MusicCart.GetMusicCart(this.HttpContext);

            ViewData["CartCount"] = cart.GetCount();
            return(PartialView("_CartReHeader"));
        }
Example #2
0
        private void MigrateMusicCart(string UserName)
        {
            // Associate shopping cart items with logged-in user
            var cart = MusicCart.GetMusicCart(this.HttpContext);

            cart.MigrateCart(UserName);
            Session[MusicCart.CartSessionKey] = UserName;
        }
        public ActionResult AddMusicCart(int id)
        {
            // Retrieve the album from bd
            var addedAlbum = db.Albums.Single(album => album.AlbumId == id);
            // Add album to the shopping cart
            var cart = MusicCart.GetMusicCart(this.HttpContext);

            cart.AddMusicCart(addedAlbum);
            // Go back to the main page for more shopping
            return(RedirectToAction("Index", "Store"));
        }
        //


        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            var cart = MusicCart.GetMusicCart(this.HttpContext);
            // Get the name of the album to display confirmation
            string albumName = db.Carts.Single(item => item.RecordId == id).Album.Title;
            // Remove from cart
            int itemCount = cart.RemoveFromCart(id);

            // Validation success
            TempData["Success"] = albumName + " " + "has been removed from your shopping cart.";
            return(RedirectToAction("Index", "MusicCart"));
        }
        // GET: /MusicCart/
        public ActionResult Index()

        {   // create the user/guid
            var cart = MusicCart.GetMusicCart(this.HttpContext);

            // Set up ViewModel
            var viewModel = new MusicCartViewModel
            {
                CartAlbums = cart.GetCartAlbums(),
                CartTotal  = cart.GetCartTotal()
            };

            return(View(viewModel));
        }
        public ActionResult AddressAndPayment([Bind(Include = "FirstName,LastName,Address,City,State,PostalCode,Phone,Email,AccountNumber,SecurityCode")] Order order)
        {
            if (ModelState.IsValid)
            {
                order.Username  = User.Identity.Name;
                order.OrderDate = DateTime.Now;
                //Save Order
                db.Orders.Add(order);
                db.SaveChanges();
            }
            //Process the order
            var cart = MusicCart.GetMusicCart(this.HttpContext);

            cart.CreateOrder(order);

            return(RedirectToAction("CheckoutComplete", new { id = order.OrderId }));
        }