public void GetCustomersPaymentTypes()
        {
            Customer _currentCustomer = new Customer();

            _currentCustomer.customerID     = 1;
            CustomerManager.currentCustomer = _currentCustomer;
            var result = _ptm.GetCustomersPaymentTypes(CustomerManager.currentCustomer.customerID);

            Assert.IsType <List <PaymentType> >(result);
        }
Ejemplo n.º 2
0
        //Produces the actual menu the user will interact with. Utilizes the ordermanager, product manager, and paymenttype manager to get all relevant info to complete a customer's order.
        public static void CompleteOrderMenu(OrderManager om, ProductManager pm, PaymentTypeManager ptm)
        {
            Order activeOrder = om.GetActiveCustomerOrder(CustomerManager.currentCustomer.customerID);

            if (activeOrder.orderID == 0)
            {
                Console.WriteLine("Please add some products to your order first. Press any key to return to main menu.");
                Console.ReadKey();
                return;
            }
            activeOrder.products = pm.GetProductsOnOrder(activeOrder.orderID);
            double orderTotal     = activeOrder.products.Sum(product => product.price);
            string completeChoice = showCompletionOption(orderTotal);

            while (completeChoice != "Y" && completeChoice != "y" && completeChoice != "N" && completeChoice != "n")
            {
                Console.WriteLine(completeChoice);
                Console.WriteLine("Sorry, I didn't understand your input.");
                completeChoice = showCompletionOption(orderTotal);
            }
            if (completeChoice == "N" || completeChoice == "n")
            {
                Console.WriteLine("Order not completed. Press any key to return to main menu.");
                Console.ReadKey();
                return;
            }
            List <PaymentType> customersPaymentTypes = ptm.GetCustomersPaymentTypes(CustomerManager.currentCustomer.customerID);
            int ptindex = 1;

            Console.WriteLine("Please select a previously stored payment option:");
            foreach (PaymentType paymenttype in customersPaymentTypes)
            {
                Console.WriteLine($"{ptindex}. {paymenttype.name}");
                ptindex++;
            }
            Console.WriteLine("> ");
            int paymentChoiceIndex = int.Parse(Console.ReadLine());

            paymentChoiceIndex       -= 1;
            activeOrder.paymentTypeID = customersPaymentTypes[paymentChoiceIndex].paymentTypeID;
            om.CompleteOrder(activeOrder);
            Console.WriteLine("You order is now complete. Press any key to return to the main menu.");
            Console.ReadKey();
            return;
        }