Esempio n. 1
0
 public PlaceOrderService(
     IRequestCookieCollection cookiesIn,
     IResponseCookies cookiesOut,
     IPlaceOrderBizLogic placeOrder)
 {
     _basketCookie = new BasketCookie(cookiesIn, cookiesOut);
     _placeOrder   = placeOrder;
 }
        public async Task <IActionResult> PlaceOrder(bool acceptTAndCs, [FromServices] IPlaceOrderBizLogic bizLogic)
        {
            var service   = new PlaceOrderService(HttpContext.Request.Cookies, HttpContext.Response.Cookies, bizLogic);
            var bizStatus = await service.PlaceOrderAndClearBasketAsync(acceptTAndCs);

            if (bizStatus.IsValid)
            {
                return(RedirectToAction("ConfirmOrder", "Orders", new { orderId = bizStatus.Result }));
            }

            //Otherwise errors, so copy over and redisplay
            bizStatus.CopyErrorsToModelState(ModelState);
            var listService = new CheckoutListService(_context, HttpContext.Request.Cookies);

            SetupTraceInfo();
            return(View(listService.GetCheckoutList()));
        }