예제 #1
0
        public void makeBooking()
        {
            string roomName;
            string date;
            string time;
            string studentId;

            // Check room availability, if room is in slot list
            do
            {
                Console.WriteLine("Enter room name: ");
                roomName = Console.ReadLine();
            } while (!UtilTool.checkSlotRoom(roomName));

            do
            {
                Console.WriteLine("Enter date for slot (dd-mm-yyyy)");
                date = Console.ReadLine();
            } while (!UtilTool.checkSlotDate(date));

            do
            {
                Console.WriteLine("Enter time for slot (hh:mm): ");
                time = Console.ReadLine();
            } while (!UtilTool.checkSlotTime(time));

            //check student ID in database
            Console.WriteLine("Enter student ID: ");
            studentId = Console.ReadLine();
            if (!UtilTool.checkStudentID(studentId))
            {
                return;
            }

            if (!checkMaxBooking(studentId, date))
            {
                return;
            }

            foreach (Slots slots in Program.slotList)
            {
                // A slot can have a maximum of 1 student booked into it
                if (roomName == slots.room && date == slots.date && time == slots.start && (slots.booking == null || slots.booking == ""))
                {
                    slots.booking = studentId;
                    updateBookingDatabase(roomName, date, time, studentId);
                    Console.WriteLine("You add a new booking");
                    return;
                }
            }
            Console.WriteLine("This room has been booked");
        }
예제 #2
0
        // Student submenu
        public override void Menu()
        {
            Console.WriteLine("--------------------");
            Console.WriteLine("--- Student menu --- ");
            do
            {
                Console.WriteLine("--------------------------------------------------------------------");
                Console.WriteLine("1. List students 2.Staff availability 3.Make booking 4.Cancel booking 5.Exit");
                //check input
                do
                {
                    input = Console.ReadLine();
                }while (!UtilTool.checkInput(input));

                stSelection = int.Parse(input);

                if (stSelection == 1)
                {
                    Console.WriteLine("--- List students ---");
                    foreach (Students s in Program.studentList)
                    {
                        Console.WriteLine(s.id + " " + s.name + " " + s.email);
                    }
                    Console.WriteLine("--------------------");
                }
                else if (stSelection == 2)
                {
                    Console.WriteLine("--- Staff availability---");
                    string date;
                    string staffId;
                    do
                    {
                        Console.WriteLine("Enter date for staff availability (dd-mm-yyyy): ");
                        date = Console.ReadLine();
                    } while (!UtilTool.checkSlotDate(date));

                    do
                    {
                        Console.WriteLine("Enter staff ID: ");
                        staffId = Console.ReadLine();
                    } while (!UtilTool.checkStaffId(staffId));

                    UtilTool.printAvailableStaff(date, staffId);
                    Console.WriteLine("--------------------");
                }
                else if (stSelection == 3)
                {
                    Console.WriteLine("--- Make booking ---");
                    makeBooking();
                    Console.WriteLine("----------------------");
                }
                else if (stSelection == 4)
                {
                    Console.WriteLine("--- Cancel booking ---");
                    cancelBooking();
                    Console.WriteLine("--------------------");
                }
                else if (stSelection == 5)
                {
                    Console.WriteLine("--- Back to main menu --- ");
                    Console.WriteLine("--------------------");
                    break;
                }
            } while (stSelection != 5);
        }