public OrderConfirmationEmailTemplateViewModelBuilder(string orderNumber, CheckoutDetailsModel model, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemBuilder) { this.orderNumber = orderNumber; this.model = model; this.shoppingCart = shoppingCart; this.cartItemBuilder = cartItemBuilder; }
public ReviewOrderViewModelBuilder(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemViewModelBuilder , IMappingEngine mapper) { this.checkoutDetailsModel = checkoutDetailsModel; this.shoppingCart = shoppingCart; this.cartItemViewModelBuilder = cartItemViewModelBuilder; this.mapper = mapper; }
public BillingViewModelBuilder(CheckoutDetailsModel checkoutDetailsModel, IAuthentication authentication,ICustomerAccountService accountService, IMappingEngine mapper) { this.checkoutDetailsModel = checkoutDetailsModel; this.authentication = authentication; this.accountService = accountService; this.mapper = mapper; }
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); }
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; }
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; }
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()); }
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); }
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; }
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); }
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; }
public OrderConfirmationViewModelBuilder(int orderID, CheckoutDetailsModel checkoutDetails) { this.orderID = orderID; this.checkoutDetails = checkoutDetails; }