Ejemplo n.º 1
0
        public JsonResult ClearQuotedCart()
        {
            _cartServiceB2B.DeleteCart(Cart);
            _cart = _cartServiceB2B.CreateNewCart();

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
        public ActionResult LoadOrder(int orderLink)
        {
            bool success       = false;
            var  purchaseOrder = _orderRepository.Load <IPurchaseOrder>(orderLink) as PurchaseOrder;

            DateTime quoteExpireDate;

            DateTime.TryParse(purchaseOrder[Constants.Quote.QuoteExpireDate].ToString(), out quoteExpireDate);
            if (DateTime.Compare(DateTime.Now, quoteExpireDate) > 0)
            {
                return(Json(new { success = success }));
            }
            if (Cart != null && Cart.OrderLink != null)
            {
                _orderRepository.Delete(Cart.OrderLink);
            }

            _cart = _cartServiceB2B.CreateNewCart();
            var returnedCart = _cartServiceB2B.PlaceOrderToCart(purchaseOrder, _cart);

            returnedCart.Properties[Constants.Quote.ParentOrderGroupId] = purchaseOrder.OrderGroupId;
            _orderRepository.Save(returnedCart);

            // Get URL of the checkout page
            var homePage     = DataFactory.Instance.GetPage(ContentReference.StartPage);
            var checkoutPage = DataFactory.Instance.GetChildren <CheckoutPage>(homePage.PageLink).FirstOrDefault();

            //TODO replace with content loader if possible and extend type to get link url
            //var checkoutPage = _contentLoader.Get<StartPage>(ContentReference.StartPage).CheckoutPage;
            _cartService.ValidateCart(returnedCart);
            return(Json(new { link = checkoutPage.LinkURL }));
        }