//
        // GET: /Checkout/AddressAndPayment
        public ActionResult AddressAndPayment()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            ViewBag.Cart = viewModel;

            return View();
        }
        //
        // GET: /ShoppingCart/
        public ActionResult Index(string message)
        {
            ViewBag.UpdateMessage = message;

            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };
            // Return the view
            return View(viewModel);
        }
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var shoppCart = ShoppingCart.GetCart(this.HttpContext);
            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = shoppCart.GetCartItems(),
                CartTotal = shoppCart.GetTotal()
            };

            var order = new Order();

            using (var dbContextTransaction = storeDB.Database.BeginTransaction())
            {

                try
                {
                    TryUpdateModel(order);

                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    storeDB.Orders.Add(order);
                    storeDB.SaveChanges();
                    //Process the order
                    shoppCart.CreateOrder(order);
                    dbContextTransaction.Commit();

                    return RedirectToAction("Complete",
                        new { id = order.ID });
                }
                catch (Exception)
                {
                    dbContextTransaction.Rollback();
                    ModelState.AddModelError("", "There was an error while processing your order, please try again.");
                }
            }

            ViewBag.Cart = viewModel;
            return View(order);
        }