public OrderConfirmationEmailTemplateViewModel Build()
        {
            var emailTemplate = new OrderConfirmationEmailTemplateViewModel()
                                    {
                                        Email = model.Email,
                                        OrderNumber = orderNumber,
                                        Name = model.FirstName + " " + model.LastName
                                    };

            emailTemplate.Items = cartItemBuilder.Build(shoppingCart.Items);
            emailTemplate.PaymentMethod = model.PaymentMethod;

            if (emailTemplate.PaymentMethod ==PaymentMethod.CraditCard)
            {
                emailTemplate.CCType = model.CreditCardViewModel.CreditCart;

                var length = model.CreditCardViewModel.CreditCardsNumber.Length;
                var zeroBaseIndex = length - 4;

                emailTemplate.CCLast4Digits = model.CreditCardViewModel.CreditCardsNumber.Substring(zeroBaseIndex, 4);

            }

            return emailTemplate;
        }
Ejemplo n.º 2
0
 public void OrderConfirmation_ShouldSetTheViewModelCorrectly()
 {
     var mailer = MockRepository.GeneratePartialMock<UserMailer>();
     mailer.Stub(x => x.PopulateBody(Arg<MailMessage>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<Dictionary<string, string>>.Is.Anything));
     var model = new OrderConfirmationEmailTemplateViewModel();
     //Act
     mailer.OrderConfirmation(Tests.SAMPLE_EMAIL_ADDRESS, model);
     //Assert
     mailer.ViewData.Model.GetType().ToString().Should().Be(model.GetType().ToString());
 }
Ejemplo n.º 3
0
        public void BestOfferCustomer_ShouldRenderTheRightView()
        {
            //Arrange

            var mailer = MockRepository.GeneratePartialMock<UserMailer>();
            mailer.Expect(x => x.PopulateBody(Arg<MailMessage>.Is.Anything, Arg<string>.Is.Equal("OrderConfirmation"), Arg<string>.Is.Anything, Arg<Dictionary<string, string>>.Is.Anything));
            var model = new OrderConfirmationEmailTemplateViewModel();
            //Act
            mailer.OrderConfirmation(Tests.SAMPLE_EMAIL_ADDRESS, model);
            //Assert
            mailer.VerifyAllExpectations();
        }
Ejemplo n.º 4
0
        public MailMessage OrderConfirmation(string mailTo, OrderConfirmationEmailTemplateViewModel model)
        {
            var mailMessage = new MailMessage {
                Subject = "Confirmation for order #" + model.OrderNumber
            };

            mailMessage.To.Add(mailTo);
            mailMessage.From = serviceSender;

            mailMessage = ToSendACopyOfThisMailToSystemAddBCCFields(mailMessage);

            ViewData = new ViewDataDictionary <OrderConfirmationEmailTemplateViewModel>(model);

            PopulateBody(mailMessage, "OrderConfirmation");

            return(mailMessage);
        }
        public OrderConfirmationEmailTemplateViewModel Build()
        {
            var emailTemplate = new OrderConfirmationEmailTemplateViewModel()
            {
                Email       = model.Email,
                OrderNumber = orderNumber,
                Name        = model.FirstName + " " + model.LastName
            };

            emailTemplate.Items         = cartItemBuilder.Build(shoppingCart.Items);
            emailTemplate.PaymentMethod = model.PaymentMethod;

            if (emailTemplate.PaymentMethod == PaymentMethod.CraditCard)
            {
                emailTemplate.CCType = model.CreditCardViewModel.CreditCart;

                var length        = model.CreditCardViewModel.CreditCardsNumber.Length;
                var zeroBaseIndex = length - 4;

                emailTemplate.CCLast4Digits = model.CreditCardViewModel.CreditCardsNumber.Substring(zeroBaseIndex, 4);
            }

            return(emailTemplate);
        }
Ejemplo n.º 6
0
        public MailMessage OrderConfirmation(string mailTo, OrderConfirmationEmailTemplateViewModel model)
        {
            var mailMessage = new MailMessage { Subject = "Confirmation for order #" + model.OrderNumber };

            mailMessage.To.Add(mailTo);
            mailMessage.From = serviceSender;

            mailMessage = ToSendACopyOfThisMailToSystemAddBCCFields(mailMessage);

            ViewData = new ViewDataDictionary<OrderConfirmationEmailTemplateViewModel>(model);

            PopulateBody(mailMessage, "OrderConfirmation");

            return mailMessage;
        }