Пример #1
0
        public void ListSlotsView()
        {
            Console.WriteLine("--- List slots ---");

            bool   firstDateTry = true;
            string date         = null;

            do
            {
                if (!firstDateTry)
                {
                    Console.WriteLine($"{date} is not a valid date. Please try again!");
                }
                firstDateTry = false;

                Console.WriteLine("Enter date for slots (dd-mm-yyyy): ");
                date = Console.ReadLine();
            } while (!Utils.ValidateDate(date));

            SlotController slotController = new SlotController();

            List <SlotModel> slots = slotController.GetSlotsByDate(DateTime.ParseExact($"{date} 00:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture));

            Console.WriteLine($"Slots on {date}:");
            Console.WriteLine("\tRoom name \tStart time \tStaff ID \tBookings");


            foreach (var slot in slots)
            {
                string time      = slot.startTime.ToString("HH:mm");
                string studentId = slot.student == null ? "-" : slot.student.userId;
                Console.WriteLine($"\t{slot.room.RoomId} \t{time} \t{slot.staff.userId} \t{studentId}");
            }
        }
Пример #2
0
        public void ListStaffAvailability()
        {
            Console.WriteLine("--- List slots ---");

            SlotController  slotController  = new SlotController();
            StaffController staffController = new StaffController();

            bool   firstDateTry = true;
            string date         = null;

            do
            {
                if (!firstDateTry)
                {
                    Console.WriteLine($"{date} is not a valid date. Please try again!");
                }
                firstDateTry = false;

                Console.WriteLine("Enter date for staff availability (dd-mm-yyyy): ");
                date = Console.ReadLine();
            } while (!Utils.ValidateDate(date));

            bool   firstStaffTry = true;
            string staffId       = null;

            do
            {
                if (!firstStaffTry)
                {
                    Console.WriteLine($"{staffId} is not a valid staff. Please try again!");
                }
                firstStaffTry = false;

                Console.WriteLine("Enter staff ID: ");
                staffId = Console.ReadLine();
            } while (!(staffController.CheckIfUserExists(staffId) && staffId.StartsWith('e')));

            var slots = slotController.GetSlotsByDate(DateTime.ParseExact($"{date} 00:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture)).Where(x => x.staff.userId.Equals(staffId)).Where(x => x.student == null);

            Console.WriteLine("\tRoom name \tStart time \tStaff ID \tBookings");
            foreach (var slot in slots)
            {
                string time      = slot.startTime.ToString("HH:mm");
                string studentId = slot.student == null ? "-" : slot.student.userId;
                Console.WriteLine($"\t{slot.room.RoomId} \t{time} \t{slot.staff.userId} \t{studentId}");
            }
        }
Пример #3
0
        public void RoomAvailabilityView()
        {
            SlotController slotController = new SlotController();
            RoomController roomController = new RoomController();

            bool firstRoomTry = true;
            char roomId       = ' ';

            do
            {
                if (!firstRoomTry)
                {
                    Console.WriteLine($"Room {roomId} does not exists. Please try again!");
                }

                firstRoomTry = false;
                Console.WriteLine("Enter room name: ");
                roomId = Console.ReadKey().KeyChar;
                Console.WriteLine();
            } while (!roomController.CheckIfRoomExists(roomId.ToString()));


            bool   firstDateTry = true;
            string date         = null;

            do
            {
                if (!firstDateTry)
                {
                    Console.WriteLine($"{date} is not a valid date. Please try again!");
                }
                firstDateTry = false;

                Console.WriteLine("Enter date for slot (dd-mm-yyyy): ");
                date = Console.ReadLine();
            } while (!Utils.ValidateDate(date));

            DateTime dateTime = DateTime.ParseExact($"{date} 00:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            var slots = slotController.GetSlotsByDate(dateTime).Where(x => x.room.RoomId.ToString()[0] == roomId);

            Console.WriteLine();
            Console.WriteLine($"\tStart Time\tEnd Time");

            for (int i = 9; i < 13; i++)
            {
                string iStr;
                if (i.ToString().Length == 1)
                {
                    iStr = "0" + i.ToString();
                }
                else
                {
                    iStr = i.ToString();
                }
                DateTime startTime = DateTime.ParseExact($"{date} {iStr}:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                DateTime endTime   = DateTime.ParseExact($"{date} {Convert.ToInt32(iStr) + 1}:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

                var startTimeStr = startTime.ToString("HH:mm");
                var endTimeStr   = endTime.ToString("HH:mm");

                bool exists = false;
                foreach (var slot in slots)
                {
                    string time = slot.startTime.ToString("HH");
                    if (time == iStr)
                    {
                        exists = true;
                    }
                }

                if (!exists)
                {
                    Console.WriteLine($"\t{startTimeStr}\t{endTimeStr}");
                }
            }
        }