Пример #1
0
        public ActionResult ReviewOrder(CheckoutDetailsModel checkoutDetailsModel)
        {
            if (CheckIfCartSessionTimedoutOrCartIsEmpty())
            {
                return(RedirectToAction("CheckoutSessionTimeout"));
            }
            var shoppingCart = shoppingCartWrapper.Get();

            var cartItemViewModelBuilder = new CartItemViewModelBuilder(jewelRepository, diamondRepository, mapper);
            var builder   = new ReviewOrderViewModelBuilder(checkoutDetailsModel, shoppingCart, cartItemViewModelBuilder, mapper);
            var viewModel = builder.Build();

            if (checkoutDetailsModel.PaymentMethod == PaymentMethod.PayPal)
            {
                var orderNumber = SaveOrderAndEmail(checkoutDetailsModel, shoppingCart);
                viewModel.OrderNumber = orderNumber;
            }

            return(View(viewModel));
        }
        private ReviewOrderViewModelBuilder CreateDefaultReviewOrderViewModelBuilder()
        {
            var checkoutDetailsModel = DefaultCheckoutDetailsModel();


            var shoppingCart = MockRepository.GenerateStub <IShoppingCart>();

            shoppingCart.Stub(x => x.TotalPrice).Return(10000);
            shoppingCart.Stub(x => x.Items).Return(new List <ICartItem>()
            {
                FakeJewelCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, Tests.SAMPLE_JEWEL_SIZE_725, JewelMediaType.WhiteGold,
                                  (decimal)9999.99)
            });

            var jewelryRepository        = new FakeJewelRepository(new FakeSettingManager());
            var diamondRepository        = new FakeDiamondRepository(mapper);
            var cartItemViewModelBuilder = new CartItemViewModelBuilder(jewelryRepository, diamondRepository,
                                                                        mapper);

            var builder = new ReviewOrderViewModelBuilder(checkoutDetailsModel, shoppingCart, cartItemViewModelBuilder, mapper);

            return(builder);
        }