public OrderConfirmationEmailTemplateViewModelBuilder(string orderNumber, CheckoutDetailsModel model, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemBuilder)
 {
     this.orderNumber = orderNumber;
     this.model = model;
     this.shoppingCart = shoppingCart;
     this.cartItemBuilder = cartItemBuilder;
 }
コード例 #2
0
 public ReviewOrderViewModelBuilder(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemViewModelBuilder , IMappingEngine mapper)
 {
     this.checkoutDetailsModel = checkoutDetailsModel;
     this.shoppingCart = shoppingCart;
     this.cartItemViewModelBuilder = cartItemViewModelBuilder;
     this.mapper = mapper;
 }
コード例 #3
0
 public BillingViewModelBuilder(CheckoutDetailsModel checkoutDetailsModel, IAuthentication authentication,ICustomerAccountService accountService, IMappingEngine mapper)
 {
     this.checkoutDetailsModel = checkoutDetailsModel;
     this.authentication = authentication;
     this.accountService = accountService;
     this.mapper = mapper;
 }
コード例 #4
0
        public ActionResult Billing(CheckoutDetailsModel checkoutDetailsModel)
        {
            if (CheckIfCartSessionTimedoutOrCartIsEmpty())
            {
                return RedirectToAction("CheckoutSessionTimeout");
            }
            if (!String.IsNullOrEmpty(Request.Form["LoginEmail"]))
            {
                var js = new JavaScriptSerializer();

                var jsonModel = js.Serialize(checkoutDetailsModel);

                return RedirectToAction("ProcessSignin", "MyAccount", new RouteValueDictionary
                                                                   {
                                                                       {"RedirectMode",RedirectMode.Route},
                                                                       {"RouteController","Checkout"},
                                                                       {"RouteAction","Billing"},
                                                                       {"Email",Request.Form["LoginEmail"]},
                                                                       {"Password",Request.Form["LoginPassword"]},
                                                                       {"JSONEncodedRouteValues",jsonModel},
                                                                       {"RouteValuesModelClassName",checkoutDetailsModel.GetType().FullName}

                                                                   });

            }

            var builder = new BillingViewModelBuilder(checkoutDetailsModel, authentication,accountService,mapper);
            var viewModel = builder.Build();

            return View(viewModel);
        }
コード例 #5
0
        public static CheckoutDetailsModel DefaultCheckoutDetailsModel()
        {
            var details = new CheckoutDetailsModel()
                              {
                                  BillingAddress = new AddressViewModel()
                                                       {
                                                           Address1 = "billingaddr1",

                                                           City = "billingcity",
                                                           CountryID = 10,
                                                           FirstName = "billingfirstname",
                                                           LastName = "billinglastname",
                                                           Phone = "billingphone",
                                                           StateID = 20,
                                                           ZipCode = "billingzipcode",
                                                           Country = "billingcountry",
                                                           State = "billingstate"

                                                       },
                                  ShippingAddress = new AddressViewModel()
                                                        {
                                                            Address1 = "shippingaddr1",

                                                            City = "shippingcity",
                                                            CountryID = 10,
                                                            FirstName = "shippingfirstname",
                                                            LastName = "shippinglastname",
                                                            Phone = "shippingphone",
                                                            StateID = 20,
                                                            ZipCode = "shippingzipcode",
                                                            Country = "shippingcountry",
                                                            State = "shippingstate"

                                                        },
                                  Comment = "comment",
                                  Email = "email",
                                  FirstName = "firstname",
                                  LastName = "lastname",
                                  PaymentMethod = PaymentMethod.CraditCard,
                                  SameAddress = false,
                                  Phone = "phone",
                                  CreditCardViewModel = new CreditCardViewModel()
                                                {
                                                    CCV = "000",
                                                    CreditCardsNumber = "12345",
                                                    CreditCardID = 1,
                                                    Month = 1,
                                                    Year = 2011
                                                }
                              };
            return details;
        }
コード例 #6
0
ファイル: OrderBuilder.cs プロジェクト: mamluka/JewelryONet
 public Order Build(CheckoutDetailsModel details)
 {
     var order = mapper.Map<CheckoutDetailsModel, Order>(details);
     order.TotalPrice = shoppingCart.TotalPrice;
     order.Items = shoppingCart.Items;
     if (authentication.IsSignedIn())
     {
         var customer = authentication.CustomerData;
         order.FirstName = customer.FirstName;
         order.LastName = customer.LastName;
         order.Email = customer.Email;
         order.Phone = order.BillingAddress.Phone;
     }
     return order;
 }
コード例 #7
0
 public void Build_ShouldReturnTheCorrectOrderNumberAndEmail()
 {
     //Arrange
     var orderNumber = Tests.NUMBER_THAT_IS_ASSERTED_WITH_BUT_HAS_NO_MEANING;
     var checkoutDetails = new CheckoutDetailsModel()
                               {
                                   Email = Tests.STRING_THAT_IS_ASSERTED_BUT_HAS_NO_MEANING
                               };
     var builder = new OrderConfirmationViewModelBuilder(orderNumber,checkoutDetails);
     //Act
     var viewModel = builder.Build();
     //Assert
     viewModel.Email.Should().Be(Tests.STRING_THAT_IS_ASSERTED_BUT_HAS_NO_MEANING);
     viewModel.OrderNumber.Should().Be(orderNumber.ToString());
 }
コード例 #8
0
ファイル: OrderBuilder.cs プロジェクト: rebider/JewelryONet
        public Order Build(CheckoutDetailsModel details)
        {
            var order = mapper.Map <CheckoutDetailsModel, Order>(details);

            order.TotalPrice = shoppingCart.TotalPrice;
            order.Items      = shoppingCart.Items;
            if (authentication.IsSignedIn())
            {
                var customer = authentication.CustomerData;
                order.FirstName = customer.FirstName;
                order.LastName  = customer.LastName;
                order.Email     = customer.Email;
                order.Phone     = order.BillingAddress.Phone;
            }
            return(order);
        }
コード例 #9
0
        private int SaveOrderAndEmail(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart)
        {
            var orderBuilder = new OrderBuilder(shoppingCart, authentication, mapper);
            var orderdto = orderBuilder.Build(checkoutDetailsModel);

            var orderNumber = orderRepository.Save(orderdto);

            if (orderNumber > 0)
            {
                var cartItemBuilder = new CartItemViewModelBuilder(jewelRepository, diamondRepository, mapper);
                var emailTemplateBuilder = new OrderConfirmationEmailTemplateViewModelBuilder(orderNumber.ToString(),
                                                                                              checkoutDetailsModel,
                                                                                              shoppingCart,
                                                                                              cartItemBuilder);

                var emailTemplateViewModel = emailTemplateBuilder.Build();
                mailer.OrderConfirmation(checkoutDetailsModel.Email, emailTemplateViewModel).Send();
            }

            return orderNumber;
        }
コード例 #10
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);
        }
コード例 #11
0
        public ActionResult OrderConfirmation(CheckoutDetailsModel checkoutDetailsModel)
        {
            if (CheckIfCartSessionTimedoutOrCartIsEmpty())
            {
                return RedirectToAction("CheckoutSessionTimeout");
            }

            var shoppingCart = shoppingCartWrapper.Get();

            var orderNumber = SaveOrderAndEmail(checkoutDetailsModel, shoppingCart);

            var builder = new OrderConfirmationViewModelBuilder(orderNumber, checkoutDetailsModel);
            var viewModel = builder.Build();

            shoppingCartWrapper.Clear();

            return View(viewModel);
        }
        private OrderConfirmationEmailTemplateViewModelBuilder CreateDefaultOrderConfirmationEmailTemplateViewModelBuilder(
            string orderNumber, CheckoutDetailsModel model)
        {
            var shoppingCart = FakeFactory.ShoppingCartWith3Items();

            var jewelRepostory = new FakeJewelRepository(new FakeSettingManager());
            var diamondRepository = new FakeDiamondRepository(mapper);
            var cartItemBuilder = new CartItemViewModelBuilder(jewelRepostory, diamondRepository, mapper);

            var builder = new OrderConfirmationEmailTemplateViewModelBuilder(orderNumber, model, shoppingCart, cartItemBuilder);
            return builder;
        }
コード例 #13
0
 public OrderConfirmationViewModelBuilder(int orderID, CheckoutDetailsModel checkoutDetails)
 {
     this.orderID = orderID;
     this.checkoutDetails = checkoutDetails;
 }