コード例 #1
0
        public void showOrderHistory()
        {
            Console.Clear();
            showCustomerList();
            CustomerQueries customerQuery = new CustomerQueries();

            Console.WriteLine("Please Enter the ID of the Customer you would like to view History of");
            string input = Console.ReadLine();

            int.TryParse(input, out int result);

            if (customerQuery.existsCustomer(result))
            {
                var orders   = customerQuery.getHistory(result);
                var customer = customerQuery.getCustomer(result);
                if (orders.Count() == 0)
                {
                    Console.WriteLine($"No history Found for {customer.FirstName} {customer.LastName}");
                }
                else
                {
                    Console.WriteLine($"{customer.FirstName} {customer.LastName}");
                    Console.WriteLine("StoreID\tOrder ID\tProduct\t\tQuantity\tTotal\t\tTime");
                    foreach (var o in orders)
                    {
                        double total = o.Product.Price * o.Count;
                        Console.WriteLine($"{o.Product.Store.StoreID}\t{o.OrderID}\t\t" +
                                          $"{o.Product.Name}\t{o.Count}\t\t{total}\t\t{o.Time}");
                    }
                }
                Console.WriteLine("Press enter to return to the menu");
                Console.ReadLine();
            }
        }