コード例 #1
0
        // Displays workshop in a store
        // This will also displays the shopping cart and...
        // will not allow user to book into a workshop if cart empty
        public void DisplayWorkshops()
        {
            Console.Clear();

            List <Workshop> workshops = Workshop.All(CurrentLocation);

            // Display list of workshops
            new WorkshopsTable(workshops);


            // Display list of all orders
            if (OrderLine.all().Count() > 0)
            {
                DisplayOrders();
            }

            // Alert the user that shopping cart is filled
            Console.WriteLine();
            Console.WriteLine("You have a pending order");
            if (Workshop != null)
            {
                Console.WriteLine("ALERT: You have selected to book to {0} {1} workshop", Workshop.Location, Workshop.Type);
                Console.WriteLine("Press 'C' process your order and booking or book to another workshop");
                Console.WriteLine();
            }


            // Assign and display available functions
            AssignAvailableFunctions();
            DisplayAvailableFunctions();


            // if there are no orders, exit immediately
            if (OrderLine.all().Count() == 0)
            {
                Console.WriteLine("WARNING: You cannot book into workshop unless you create an order");
                return;
            }


            // select a workshop, if q is selected (which is 0), quit immediately
            int?choice = SelectWorkshop(workshops);

            if (choice == null)
            {
                ProcessSelectedFunction();
                return;
            }
            else if (choice == 0)
            {
                return;
            }
            else
            {
                Workshop = Workshop.Find((int)choice);
                DisplayWorkshops();
            }
        }