public static void Menu() { List <Calender> listOfCalenders = new List <Calender>(); //Kijkt of het bestand 'calender' bestaat, als dat niet zo is maakt hij deze aan if (!File.Exists(AJsonable.GetPath("Calender", "Calender"))) { for (int i = 0; i < AJsonable.GetAll <EscapeRoom>("EscapeRooms").Count; i++) { var rooms = AJsonable.GetAll <EscapeRoom>("EscapeRooms"); var cal = new Calender(rooms[i].ID); listOfCalenders.Add(cal); } JsonManager.SaveData <List <Calender> >(listOfCalenders, "Calender", "Calender"); } else { listOfCalenders = JsonManager.GetData <List <Calender> >("Calender", "Calender"); } Console.WriteLine("1. Book room\n2. Check bookings"); string option = Console.ReadLine(); if (option == "1") { BookRoom(listOfCalenders); } else if (option == "2") { CheckBookings(listOfCalenders); } }
public static void EditRoom() { Console.WriteLine("Edit rooms: "); ShowRooms(); bool isDone = false; while (!isDone) { Console.WriteLine("Which room do you want to Edit? (enter to cancel)"); Console.Write("Name: "); string roomName = Console.ReadLine(); string roomNamePath = AJsonable.GetPath("EscapeRooms", roomName); bool escapeRoomExists = File.Exists(roomNamePath); if (String.IsNullOrEmpty(roomName)) { Console.WriteLine("Editing canceled"); isDone = true; } else if (!escapeRoomExists) { Console.WriteLine($"{roomName} does not exist."); } else if (escapeRoomExists) { var room = AJsonable.Get <EscapeRoom>("EscapeRooms", roomName); string name = AskQuestion($"(current = {room.Name}) Enter new name: ", required: true); string theme = AskQuestion($"(current = {room.Theme}) Enter new theme: ", required: true); int price = Int32.Parse(AskQuestion($"(current = {room.Price}) Enter new price: ", isInt: true)); int maxPlayers = Int32.Parse(AskQuestion($"(current = {room.MaxPlayers}) Enter new max amount of players: ", isInt: true)); EscapeRoom.Delete <EscapeRoom>("EscapeRooms", roomName); var newRoom = new EscapeRoom() { ID = room.ID, Name = name, Theme = theme, Price = price, MaxPlayers = maxPlayers, MaxDuration = room.MaxDuration, SetupTime = room.SetupTime }; newRoom.Save(); Console.WriteLine(newRoom.ToString()); Console.WriteLine($"Escaperoom {newRoom.Name} succesfully edited!"); isDone = true; } } }