示例#1
0
        public async Task Purchase(FlightReservationModel flight, CancellationToken cancellationToken)
        {
            string cartId      = _cartCookieProvider.GetCartCookie();
            var    updatedCart = await _cartDataProvider.UpsertCartFlights(cartId, flight.SelectedDepartingFlight, flight.SelectedReturningFlight, cancellationToken);

            if (string.IsNullOrEmpty(cartId))
            {
                _cartCookieProvider.SetCartCookie(updatedCart.Id);
            }
        }
        public async Task Purchase(CarReservationModel car, CancellationToken cancellationToken)
        {
            string cartId      = _cartCookieProvider.GetCartCookie();
            var    updatedCart = await _cartDataProvider.UpsertCartCar(cartId, car.SelectedCar, car.NumberOfDays, cancellationToken);

            if (string.IsNullOrEmpty(cartId))
            {
                _cartCookieProvider.SetCartCookie(updatedCart.Id);
            }
        }
示例#3
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);
        }
示例#4
0
        public async Task <ItineraryModel> GetByCartId(CancellationToken cancellationToken)
        {
            string cookieId  = _cartCookieProvider.GetCartCookie();
            var    itinerary = await _itineraryDataProvider.FindItinerary(cookieId, cancellationToken);

            if (itinerary == null)
            {
                return(null);
            }

            return(await _cartDisplayProvider.LoadFullItinerary(itinerary, cancellationToken));
        }