// Staff submenu public override void Menu() { Console.WriteLine("--------------------"); Console.WriteLine("--- Staff menu ---"); do { Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine("1. List staff 2.Room availability 3.Create slot 4.Remove slot 5.Exit"); //check input do { input = Console.ReadLine(); }while (!UtilTool.checkInput(input)); sfSelection = int.Parse(input); if (sfSelection == 1) { foreach (Staffs staff in Program.staffList) { Console.WriteLine(staff.id + " " + staff.name + " " + staff.email); } } else if (sfSelection == 2) { Console.WriteLine("--- Room availability ---"); do { Console.WriteLine("Enter date for room availability (dd-mm-yyyy): "); input = Console.ReadLine(); } while (!UtilTool.checkDate(input)); UtilTool.printAvailableRoom(input); } else if (sfSelection == 3) { Console.WriteLine("--- Create slots --- ");// Create a slot createSlot(); Console.WriteLine("----------------------"); } else if (sfSelection == 4) { Console.WriteLine("--- Remove slots --- "); removeSlot(); } else if (sfSelection == 5) { Console.WriteLine("--- Back to main menu --- "); break; } } while (sfSelection != 5); }
public void removeSlot() { string roomName; string date; string time; Console.WriteLine("Enter room name: "); roomName = Console.ReadLine(); if (!UtilTool.checkRoom(roomName)) { return; } Console.WriteLine("Enter date for slot (dd-mm-yyyy): "); date = Console.ReadLine(); if (!UtilTool.checkDate(date)) { return; } Console.WriteLine("Enter time for slot (hh:mm)"); time = Console.ReadLine(); if (!UtilTool.checkTime(time)) { return; } foreach (Slots slot in Program.slotList) { if (slot.room == roomName && slot.date == date && slot.start == time && (slot.booking == null || slot.booking == "")) { Program.slotList.Remove(slot); deleteSlotFromDatabase(roomName, date, time); Console.WriteLine("Successfully removed"); return; } if (slot.room == roomName && slot.date == date && slot.start == time && (slot.booking != null || slot.booking != "")) { Console.WriteLine("Unable to remove this slot because it has been booked"); return; } } Console.WriteLine("Slot does not exist"); }
public void createSlot() { string roomName; string date; string startTime; string endTime; string staffId; string booking = null; // Check room availability do { Console.WriteLine("Enter room name: "); roomName = Console.ReadLine(); // Enter room name } while (!UtilTool.checkRoom(roomName)); do { Console.WriteLine("Enter date for slot (dd-mm-yyyy): "); date = Console.ReadLine();// Enter date } while (!UtilTool.checkDate(date)); if (!checkRoomSlot(roomName, date)) { return; } do { Console.WriteLine("Enter time for slot (hh:mm): "); startTime = Console.ReadLine(); } while (!UtilTool.checkTime(startTime)); endTime = UtilTool.GetEndTime(startTime); do { Console.WriteLine("Enter staff ID: "); staffId = Console.ReadLine(); } while (!checkMaxSlot(staffId, date)); //check staff id in database if (!UtilTool.checkStaffId(staffId)) { return; } foreach (Slots s in Program.slotList) { if (roomName == s.room && date == s.date && startTime == s.start) { Console.WriteLine("Unable to create because it has been created"); return; } } Slots slot = new Slots(roomName, date, startTime, endTime, staffId, booking); Program.slotList.Add(slot); addSlotToDataBase(roomName, date, startTime, endTime, staffId); Console.WriteLine("You created a new slot"); }