예제 #1
0
        public void GetOrderHistory()
        {
            bool     findCust = false;
            Customer customer = new Customer();

            do
            {
                customer = FindCustomer();
                if (customer == null)
                {
                    Console.WriteLine("Search again for a customer");
                }
                else
                {
                    findCust = true;
                }
            }while(!findCust);
            Console.WriteLine("Select order history format:");
            Console.WriteLine("\t[1] - Date(Ascending)\n\t[2] - Date(Descending)\n\t[3] - Total(Highest)\n\t[4] - Total(Lowest)");
            try
            {
                int option = int.Parse(Console.ReadLine());
                switch (option)
                {
                case 1:
                    foreach (var item in _orderBL.GetCustomerOrdersASC(customer.CustID))
                    {
                        Console.WriteLine(item.ToString());
                        _productBL.ProductsByOrder(item.OrderID);
                    }
                    break;

                case 2:
                    foreach (var item in _orderBL.GetCustomerOrdersDESC(customer.CustID))
                    {
                        Console.WriteLine(item.ToString());
                        _productBL.ProductsByOrder(item.OrderID);
                    }
                    break;

                case 3:
                    foreach (var item in _orderBL.GetCustomerOrdersASCTotal(customer.CustID))
                    {
                        Console.WriteLine(item.ToString());
                        _productBL.ProductsByOrder(item.OrderID);
                    }
                    break;

                case 4:
                    foreach (var item in _orderBL.GetCustomerOrdersDESCTotal(customer.CustID))
                    {
                        Console.WriteLine(item.ToString());
                        _productBL.ProductsByOrder(item.OrderID);
                    }
                    break;

                default:
                    Console.WriteLine("Incorrect option, please try again");
                    break;
                }
            }
            catch
            {
                Console.WriteLine("Error - incorrect option");
            }

            /*foreach(var item in _orderBL.GetCustomerOrders(customer.CustID))
             * {
             *  Console.WriteLine(item.ToString());
             *  _productBL.ProductsByOrder(item.OrderID);
             * }
             */
        }