public void CheckoutQuoteRequest()
        {
            WorkContext          workContext         = GetTestWorkContext();
            IQuoteRequestBuilder quoteRequestBuilder = GetQuoteRequestBuilder();
            var customer = new CustomerInfo
            {
                Id = Guid.NewGuid().ToString(),
                IsRegisteredUser = false
            };

            workContext.CurrentCustomer = customer;

            QuoteRequest quoteRequest = quoteRequestBuilder.GetOrCreateNewTransientQuoteRequestAsync(workContext.CurrentStore, customer, workContext.CurrentLanguage, workContext.CurrentCurrency).Result.QuoteRequest;

            ICatalogSearchService catalogSearchService = GetCatalogSearchService();

            Product[] searchResult = catalogSearchService.GetProductsAsync(new[] { "217be9f3d9064075821f6785dca658b9" }, ItemResponseGroup.ItemLarge).Result;
            quoteRequestBuilder.AddItem(searchResult.First(), 1);
            quoteRequestBuilder.SaveAsync().Wait();

            var quoteItem = quoteRequestBuilder.QuoteRequest.Items.First();

            quoteItem.ProposalPrices.Add(new TierPrice(quoteItem.SalePrice * 0.7, 5));
            quoteItem.ProposalPrices.Add(new TierPrice(quoteItem.SalePrice * 0.5, 10));
            quoteRequestBuilder.SaveAsync().Wait();
            quoteRequest = quoteRequestBuilder.GetOrCreateNewTransientQuoteRequestAsync(workContext.CurrentStore, customer, workContext.CurrentLanguage, workContext.CurrentCurrency).Result.QuoteRequest;

            Assert.NotNull(quoteRequest.Items);
            Assert.Equal(quoteRequest.Items.Count, 1);

            var requestItem = quoteRequest.Items.First();

            foreach (var proposalPrice in requestItem.ProposalPrices)
            {
                requestItem.SelectedTierPrice = proposalPrice;

                ICartBuilder cartBuilder = GetCartBuilder();
                cartBuilder.LoadOrCreateNewTransientCartAsync("default", workContext.CurrentStore, customer, workContext.CurrentLanguage, workContext.CurrentCurrency).Wait();
                cartBuilder.FillFromQuoteRequestAsync(quoteRequest).Wait();
                cartBuilder.SaveAsync().Wait();

                cartBuilder.LoadOrCreateNewTransientCartAsync("default", workContext.CurrentStore, customer, workContext.CurrentLanguage, workContext.CurrentCurrency).Wait();
                var cart = cartBuilder.Cart;
                var item = cart.Items.First();

                Assert.Equal(requestItem.SelectedTierPrice.ActualPrice, item.SalePrice);
                Assert.Equal(requestItem.SelectedTierPrice.Quantity, item.Quantity);
            }
        }
Exemple #2
0
        public async Task <ActionResult> Confirm([FromRoute] string number, [FromBody] QuoteRequestFormModel quoteRequest)
        {
            await _quoteRequestBuilder.LoadQuoteRequestAsync(number, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency);

            EnsureQuoteRequestBelongsToCurrentCustomer(_quoteRequestBuilder.QuoteRequest);

            _quoteRequestBuilder.Update(quoteRequest).Confirm();
            await _quoteRequestBuilder.SaveAsync();

            await _cartBuilder.TakeCartAsync(WorkContext.CurrentCart.Value);

            await _cartBuilder.FillFromQuoteRequestAsync(_quoteRequestBuilder.QuoteRequest);

            await _cartBuilder.SaveAsync();

            return(Ok());
        }
Exemple #3
0
        public async Task <ActionResult> Confirm(string number, QuoteRequestFormModel quoteRequest)
        {
            await _quoteRequestBuilder.LoadQuoteRequestAsync(number, WorkContext.CurrentLanguage, WorkContext.AllCurrencies);

            EnsureQuoteRequestBelongsToCurrentCustomer(_quoteRequestBuilder.QuoteRequest);

            _quoteRequestBuilder.Update(quoteRequest).Confirm();
            await _quoteRequestBuilder.SaveAsync();

            await _cartBuilder.TakeCartAsync(WorkContext.CurrentCart);

            await _cartBuilder.FillFromQuoteRequestAsync(_quoteRequestBuilder.QuoteRequest);

            await _cartBuilder.SaveAsync();

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }