Пример #1
0
        private void ClearCheckoutCookie(HttpContext httpContext)
        {
            var checkoutCookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies);
            var cookieService  = new CheckoutCookieService(checkoutCookie.GetValue());

            cookieService.ClearAllLineItems();
            checkoutCookie.AddOrUpdateCookie(cookieService.EncodeForCookie());
        }
Пример #2
0
        public int PlaceOrder(bool acceptTAndCs)
        {
            var checkoutService = new CheckoutCookieService(checkoutCookie.GetValue());
            var placeOrderInDto = new PlaceOrderInDto(acceptTAndCs, checkoutService.UserId, checkoutService.LineItems);
            var order           = runner.RunAction(placeOrderInDto);

            if (runner.HasErrors)
            {
                return(0);
            }

            checkoutService.ClearAllLineItems();
            checkoutCookie.AddOrUpdateCookie(checkoutService.EncodeForCookie());

            return(order.OrderId);
        }
Пример #3
0
        /// <summary>
        /// This creates the order and, if successful clears the cookie
        /// </summary>
        /// <returns>Returns the OrderId, or zero if errors</returns>
        public int PlaceOrder(bool acceptTAndCs)
        {
            var checkoutService = new CheckoutCookieService(
                _basketCookie.GetValue());

            var order = _runner.RunAction(
                new PlaceOrderInDto(acceptTAndCs,
                                    checkoutService.UserId, checkoutService.LineItems));

            if (_runner.HasErrors)
            {
                return(0);
            }

            //successful so clear the cookie line items
            checkoutService.ClearAllLineItems();
            _basketCookie.AddOrUpdateCookie(
                checkoutService.EncodeForCookie());

            return(order.OrderId);
        }
Пример #4
0
        /// <summary>
        /// This creates the order and, if successful clears the cookie
        /// </summary>
        /// <returns>Returns the OrderId, or zero if errors</returns>
        public int PlaceOrder(bool acceptTAndCs)                 //#G
        {
            var checkoutService = new CheckoutCookieService(     //#H
                _checkoutCookie.GetValue());                     //#H

            var order = _runner.RunAction(                       //#I
                new PlaceOrderInDto(acceptTAndCs,                //#I
                                    checkoutService.UserId,      //#I
                                    checkoutService.LineItems)); //#I

            if (_runner.HasErrors)
            {
                return(0);                   //#J
            }
            //successful so clear the cookie line items
            checkoutService.ClearAllLineItems();    //#K
            _checkoutCookie.AddOrUpdateCookie(      //#K
                checkoutService.EncodeForCookie()); //#K

            return(order.OrderId);                  //#L
        }
Пример #5
0
        /// <summary>
        /// This creates the order and, if successful clears the cookie
        /// </summary>
        /// <returns>Returns the OrderId, or zero if errors</returns>
        public async Task <IStatusGeneric <int> > PlaceOrderAndClearBasketAsync(bool acceptTAndCs)
        {
            var status = new StatusGenericHandler <int>();

            var checkoutService = new CheckoutCookieService(
                _basketCookie.GetValue());

            var bizStatus = await _placeOrder.CreateOrderAndSaveAsync(
                new PlaceOrderInDto(acceptTAndCs, checkoutService.UserId, checkoutService.LineItems));


            if (status.CombineStatuses(bizStatus).HasErrors)
            {
                return(status);
            }

            //successful so clear the cookie line items
            checkoutService.ClearAllLineItems();
            _basketCookie.AddOrUpdateCookie(
                checkoutService.EncodeForCookie());

            return(status.SetResult(bizStatus.Result.OrderId));
        }