Exemplo n.º 1
0
        private void ManageRoom()
        {
            bool validSelection = false;

            while (!validSelection)
            {
                Console.Clear();
                Console.WriteLine("\t\t* You are working on room management *");
                Console.WriteLine("\t\t* 1. Add room                        *");
                Console.WriteLine("\t\t* 2. Modify room                     *");
                Console.WriteLine("\t\t* 3. Delete room                     *");
                Console.WriteLine("\t\t* 4. Display rooms                   *");
                Console.WriteLine("\t\t* 5. Back to main menu               *");
                Console.WriteLine("\t\t**************************************");
                Console.Write("Enter an option(1-5): ");
                int decision = 0;
                try
                {
                    decision = System.Int32.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    decision = 0;
                }
                //var decision = System.Int32.Parse(Console.ReadLine());
                if (decision >= 1 && decision <= 5)
                {
                    validSelection = true;
                }
                Console.WriteLine();
                switch (decision)
                {
                case 1:
                    roomManagementView.AddRoom();
                    ManageRoom();
                    break;

                case 2:
                    roomManagementView.EditRoom();
                    ManageRoom();
                    break;

                case 3:
                    roomManagementView.DeleteRoom();
                    ManageRoom();
                    break;

                case 4:
                    roomManagementView.DisplayRoom();
                    Console.Write("[Enter] to continue...");
                    Console.ReadLine();
                    ManageRoom();
                    break;

                case 5:
                    Console.WriteLine("You select backing to main management selection");
                    ProcessManagementSelection();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private ClassPeriod CreateClassPeriod()
        {
            ClassPeriod classPeriod = null;

            Console.WriteLine();
            Console.WriteLine("\t\tRoom List\t\t");
            rmv.DisplayRoom();
            Console.Write("\nEnter room name: ");
            string roomName = Console.ReadLine();
            Room   room     = roomController.SearchRoom(roomName);

            while (roomController.SearchRoom(roomName) == null)
            {
                Console.Write("\nThis room never exists. Enter room id: ");
                roomName = Console.ReadLine();
            }

            Console.Write("\nEnter a day of week(Monday - Friday): ");
            string dayOfWeek = Console.ReadLine();

            dayOfWeek = dayOfWeek.ToLower();
            while (!Validate.ValidWeekDayString(dayOfWeek))
            {
                Console.Write("\nInvalid day of week. Please enter again(Monday - Friday): ");
                dayOfWeek = Console.ReadLine();
            }
            dayOfWeek = dayOfWeek.ToLower();
            bool isLogic = false;

            while (!isLogic)
            {
                try
                {
                    Console.Write("\nEnter start time class(HH:MM)\nTime must satisfy block of 30 minutes: ");
                    var      st        = Console.ReadLine();
                    DateTime startTime = DateTime.Parse(st);
                    while (!Validate.ValidMinute(st))
                    {
                        Console.WriteLine("Please follow format(HH:MM) and block of 30 minutes(eg. 9:30)");
                        Console.Write("> ");
                        st        = Console.ReadLine();
                        startTime = DateTime.Parse(st);
                    }

                    Console.Write("\nEnter end time class(HH:MM)\nTime must satisfy block of 30 minutes: ");
                    var      et      = Console.ReadLine();
                    DateTime endTime = DateTime.Parse(et);
                    while (!Validate.ValidMinute(et))
                    {
                        Console.WriteLine("Please follow format(HH:MM) and block of 30 minutes(eg. 9:30)");
                        Console.Write("> ");
                        et      = Console.ReadLine();
                        endTime = DateTime.Parse(et);
                    }
                    if (classController.ValidateClassTime(startTime, endTime))
                    {
                        classPeriod = new ClassPeriod(room, dayOfWeek, startTime, endTime);
                        isLogic     = true;
                        //return classPeriod;
                    }
                    else
                    {
                        Console.WriteLine("*************** Instruction *********************");
                        Console.WriteLine("Start time or end time you entered was not logic.");
                        Console.WriteLine("Minimun start time must be 8:00");
                        Console.WriteLine("Maximun start time must be 17:30");
                        Console.WriteLine("Minimun end time must be 8:30");
                        Console.WriteLine("Minimun end time must be 18:00");
                        Console.WriteLine("Start time must be earlier than end time.");
                        Console.WriteLine("*************************************************");
                    }
                }
                catch (Exception)
                {
                    isLogic = false;
                }
            }
            return(classPeriod);
            //return classPeriod;
        }