private void PlaceOrder()
        {
            var customer = new Customer();
            // Populate instance

            var order = new Order();
            // Populate instance
            var payment = new Payment();
            //populate payment info from UI

            var orderController = new OrderController();
            orderController.PlaceOrder(customer, order, payment, allowSplitOrders:false, emailReceipt:true);
        }
Beispiel #2
0
        public void ProcessPayment(Payment payment)
        {
            // -- Process the payment --
            // If credit card, 
            // process the credit card payment.
            // If PayPal, 
            // process the PayPal payment.
            // If there is a payment problem, notify the user.
            // Open a connection
            // Set stored procedure parameters with the payment data.
            // Call the save stored procedure.

        }
        public void PlaceOrderTestNullOrder()
        {
            // -- Arrange
            var orderController = new OrderController();
            var customer = new Customer() { EmailAddress = "*****@*****.**" };
            Order order = null;
            var payment = new Payment() { PaymentType = 1 };

            // -- Actual
            OperationResult op = orderController.PlaceOrder(customer, order, payment, allowSplitOrders: true,
                emailReceipt: true);

            // -- Assertion
        }
        public void PlaceOrderTest()
        {
            // -- Arrange
            var orderController = new OrderController();
            var customer = new Customer() { EmailAddress = "*****@*****.**" };
            var order = new Order();
            var payment = new Payment() { PaymentType = 1 };

            // -- Actual
            OperationResult op = orderController.PlaceOrder(customer, order, payment, allowSplitOrders: true,
                emailReceipt: true);

            // -- Assertion
            Assert.AreEqual(true, op.Success);
            Assert.AreEqual(0, op.MessageList.Count);
        }
Beispiel #5
0
        private void PlaceOrder()
        {
            var allowSplitOrders = true;
            var emailReceipt = true;

            var customer = new Customer();
            // Populate the customer instance

            var order = new Order();
            // Populate the order instance

            var payment = new Payment();
            // Populate the payment info from the UI

            var orderController = new OrderController();
            orderController.PlaceOrder(customer, order, payment,
                allowSplitOrders: false, emailReceipt: true); // allowSplitOrders: false, emailReceipt: true
        }
        public OperationResult PlaceOrder(Customer customer, Order order, Payment payment, bool allowSplitOrders, bool emailReceipt)
        {
            // This program makes assertions that certain functions are running (as functions below)
            // These will throw a warning during debuging if an assertion isn't true
            Debug.Assert(customerRepository != null, "Missing customer repository instance N***A");
            Debug.Assert(orderRepository != null, "Missing order repository instance");
            Debug.Assert(inventoryRepository != null, "Missing inventory repository instance");
            Debug.Assert(emailLibrary != null, "Missing email library instance");

            if (customer == null) throw new ArgumentNullException("Customer instance is null");
            if (order == null) throw new ArgumentNullException("Order instance is null");
            if (payment == null) throw new ArgumentNullException("Payment instance is null");

            var op = new OperationResult();

            customerRepository.Add(customer);

            orderRepository.Add(order);

            inventoryRepository.OrderItems(order, allowSplitOrders);

            payment.ProcessPayment();

            if (emailReceipt)
            {
                var result = customer.ValidateEmail();
                if (result.Success)
                {
                    customerRepository.Update();

                    emailLibrary.SendEmail(customer.EmailAddress, "Here is your receipt");
                }
                else
                {
                    // log the messages
                    if (result.MessageList.Any())
                    {
                        op.AddMessage(result.MessageList[0]);
                    }
                }
            }
            return op;
        }
        public void PlaceOrder(Customer customer,
                                Order order,
                                Payment payment,
                                bool allowSplitOrders, bool emailReceipt)
        {
            customerRepository.Add(customer);

            orderRepository.Add(order);

            inventoryRepository.OrderItems(order, allowSplitOrders);

            payment.ProcessPayment();

            if (emailReceipt)
            {
                customer.ValidateEmail();
                customerRepository.Update();

                emailLibrary.SendEmail(customer.EmailAddress, "Here are your receipt!");
            }
        }
Beispiel #8
0
        public void PlaceOrder(Customer customer,
                                Order order,
                                Payment payment,
                                bool allowSplitOrders, bool emailReceipt)  // put objects in order put flags(bool values) at the end
        {
            customerRepository.Add(customer);

            orderRepository.Add(order);

            inventoryRepository.OrderItems(order, allowSplitOrders);

            payment.ProcessPayment(payment);

            if (emailReceipt)
            {
                customer.ValidateEmail();
                customerRepository.Update();

                emailLibrary.SendEmail(customer.EmailAddress,
                                        "Here is your receipt");
            }
        }
Beispiel #9
0
 public void processPayment(Payment payment)
 {
     //Process payment fro UI
 }