Esempio n. 1
0
        public PartialViewResult GuestCheckout(string CartID)
        {
            GuestCheckoutViewModel GCVM          = new GuestCheckoutViewModel();
            ShoppingCart           _shoppingCart = new ShoppingCart(_context);

            GCVM.GuestOrder            = new Order();
            GCVM.CartID                = CartID;
            GCVM.CurrentCart           = _shoppingCart.GetCart(CartID);
            GCVM.GuestOrder.FinalPrice = _shoppingCart.Total(GCVM.CurrentCart);
            GCVM.TotalForStripe        = _shoppingCart.StripeTotal((int)GCVM.GuestOrder.FinalPrice);
            return(PartialView("~/Views/Carts/GuestOrderCreation.cshtml", GCVM));
        }
Esempio n. 2
0
        public async Task <IActionResult> GuestOrderCreation(GuestCheckoutViewModel GCVM)
        {
            GCVM.GuestOrder.CartID  = GCVM.CartID;
            GCVM.GuestOrder.Status  = Status.Open;
            GCVM.GuestOrder.isGuest = true;
            ShoppingCart _shoppingCart = new ShoppingCart(_context);

            GCVM.CurrentCart           = _shoppingCart.GetCart(GCVM.CartID);
            GCVM.GuestOrder.FinalPrice = _shoppingCart.Total(GCVM.CurrentCart);
            GCVM.TotalForStripe        = _shoppingCart.StripeTotal((int)GCVM.GuestOrder.FinalPrice);
            await _context.Orders.AddAsync(GCVM.GuestOrder);

            await _context.SaveChangesAsync();

            CheckoutViewModel CVM = new CheckoutViewModel();

            CVM.GCVM = GCVM;
            return(View("~/Views/Carts/ConfirmOrder.cshtml", CVM));
        }