예제 #1
0
        // Make sure to return an empty cart if there isn't a purchased Itinerary
        public async Task <CartModel> Index(CancellationToken cancellationToken)
        {
            string cartId = _cartCookieProvider.GetCartCookie();
            var    cart   = await _cartDataProvider.GetCart(cartId, cancellationToken);

            if (cart != null)
            {
                return(await _cartDisplayProvider.LoadFullCart <CartModel>(cart, cancellationToken));
            }

            if ((await _itineraryController.GetByCartId(cancellationToken)) == null)
            {
                return(new CartModel()
                {
                    Id = System.Guid.Parse(cartId)
                });
            }

            return(null);
        }
        public async Task <bool> SendForProcessing(string cartId, DateTimeOffset PurchasedOn, CancellationToken cancellationToken)
        {
            var cart = await _cartDataProvider.GetCart(cartId, cancellationToken);

            if (cart != null)
            {
                await _httpClient.PostAsync <CartPersistenceModel>($"api/Itinerary/purchase?purchasedOn={System.Web.HttpUtility.UrlEncode(PurchasedOn.ToString())}", cart, new System.Net.Http.Formatting.JsonMediaTypeFormatter());

                return(true);
            }

            return(false);
        }
예제 #3
0
        public async Task <string> Purchase(string cartId, System.DateTimeOffset PurchasedOn, CancellationToken cancellationToken)
        {
            CartPersistenceModel cart = await _cartDataProvider.GetCart(cartId, cancellationToken);

            return(await Purchase(cart, PurchasedOn, cancellationToken));
        }