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"); }