public ActionResult AddressAndPayment(OrdersViewModel vm, FormCollection values)
        {
            var order = new Order();
            var cart = ShoppingCart.GetCart(HttpContext);

            TryUpdateModel(order);

            try
            {
                order.Username = User.Identity.Name;
                order.OrderDate = DateTime.Now;
                order.IsProcessed = false;
                order.Total = cart.GetTotal();
                //Save Order
                UoW.Orders.Add(order);
                UoW.SaveChanges();

                //Process the order
                cart.CreateOrder(order);
                TempData["toast"] = "<script> $(document).ready(function () {" +
                             "toastr.options = { 'positionClass': 'toast-bottom-right' };" +
                             "toastr.success('Order has been sent for processing!');});</script>";

                return RedirectToAction("Complete",
                    new { id = order.OrderId });
            }
            catch (Exception e)
            {
                //Invalid - redisplay with errors
                return View(vm);
            }
        }
        public int CreateOrder(Order order)
        {
            decimal orderTotal = 0;

            var cartItems = GetCartItems();

            // Iterate over the items in the cart, adding the order details for each
            foreach (var item in cartItems)
            {
                var orderDetail = new OrderDetail
                {
                    GameId = item.GameId,
                    OrderId = order.OrderId,
                    UnitPrice = item.Games.Price,
                    Quantity = item.Count
                };

                // Set the order total of the shopping cart
                orderTotal += (item.Count * item.Games.Price);

                storeDB.OrderDetails.Add(orderDetail);

            }

            // Set the order's total to the orderTotal count
            order.Total = orderTotal;

            // Save the order
            storeDB.SaveChanges();

            // Empty the shopping cart
            EmptyCart();

            // Return the OrderId as the confirmation number
            return order.OrderId;
        }