private void UpdateBadge() { Console.Clear(); ListBadgeNums(); Console.Write("\n\t Enter Badge Number you want to update:\n" + "\n\t Badge #: "); string input = Console.ReadLine(); int badgeNum = Convert.ToInt32(input); Badge badge = _repo.GetByBadgeNum(badgeNum); if (_repo.DictContainsKey(badgeNum)) { Console.WriteLine($"\n\t #{badge.BadgeID} has access to doors:"); ShowDoors(badge); bool updateDoors = true; while (updateDoors) { Console.Clear(); Console.WriteLine($"\n\t What would you like to do?\n" + $"\n\t 1. Remove a door\n" + $"\t 2. Add a Door\n" + $"\t 3. Back to Main Menu"); Console.Write("\n\t "); string inputTwo = Console.ReadLine(); switch (inputTwo.ToLower()) { case "1": case "one": case "remove": case "remove a door": Console.Clear(); Console.WriteLine($"\n\t Which door would you like to remove?\n" + $"\n\t"); ShowDoors(badge); Console.Write("\n\t Door: "); string doorToRemove = Console.ReadLine(); Enum.TryParse(doorToRemove.ToUpper(), out DoorAccess removeDoor); _repo.RemoveDoorAccess(badgeNum, removeDoor); Console.WriteLine($"\n\t Badge #{badge.BadgeID} now has access to doors "); ShowDoors(badge); Console.ReadKey(); break; case "2": case "two": case "add": case "add a door": bool addDoorBool = true; while (addDoorBool) { Console.Clear(); Console.WriteLine($"\n\t Badge #{badge.BadgeID} currently has access to doors "); ShowDoors(badge); Console.Write($"\n\t Please choose a door to grant access\n" + $"\n\t\t1. A1\n" + $"\t\t2. A2\n" + $"\t\t3. A3\n" + $"\t\t4. A4\n" + $"\t\t5. B1\n" + $"\t\t6. B2\n" + $"\t\t7. B3\n" + $"\t\t8. B4\n" + $"\n\t # "); int addDoor = _repo.StringisInt(Console.ReadLine()); if (addDoor <= 8 && addDoor >= 1) { Console.Clear(); if (DoorDupCheck(badge, addDoor)) { _repo.AddDoorAccess(badgeNum, addDoor); Console.WriteLine($"\n\t Badge #{badge.BadgeID} now has access to doors\n" + $"\n\t "); ShowDoors(badge); bool yesNo = true; while (yesNo) { Console.Write($"\n\tWould you like to add another door?\n" + $"\n\t y/n "); string inputThree = Console.ReadLine(); switch (inputThree) { case "y": case "yes": yesNo = false; break; case "n": case "no": yesNo = false; addDoorBool = false; break; default: Console.WriteLine($"\n\t Yes or No?"); break; } } } else { Console.WriteLine($"\n\t Badge already has Access to that door"); Console.ReadKey(); } } else { Console.Clear(); Console.WriteLine($"\n\t Please choose a door 1-8"); Console.ReadKey(); } } break; case "3": case "three": case "exit": case "main menu": case "back": case "back to main menu": updateDoors = false; break; default: Console.WriteLine($"\n\t Not a valid option"); break; } } } else { Console.WriteLine("\n\t That is not a valid Badge #"); Console.ReadKey(); UpdateBadge(); } }
private void AddBadge() { Badge badge = new Badge(); List <DoorAccess> doorList = new List <DoorAccess>(); Console.Clear(); Console.Write($"\n\t What is the number on the badge? # "); badge.BadgeID = _repo.StringisInt(Console.ReadLine()); bool addMoreDoors = true; while (addMoreDoors) { Console.Clear(); Console.Write($"\n\t Please choose a door to grant access\n" + $"\n\t\t1. A1\n" + $"\t\t2. A2\n" + $"\t\t3. A3\n" + $"\t\t4. A4\n" + $"\t\t5. B1\n" + $"\t\t6. B2\n" + $"\t\t7. B3\n" + $"\t\t8. B4\n" + $"\n\t # "); int input = _repo.StringisInt(Console.ReadLine()); if (input <= 8 && input >= 1) { doorList.Add((DoorAccess)input); Console.Write($"\n\t Would you like to add another door?\n" + $"\n\t\t y/n "); string yN = Console.ReadLine(); bool yesNo = true; while (yesNo) { switch (yN.ToLower()) { case "y": case "yes": yesNo = false; break; case "n": case "no": badge.DoorAccess = doorList; _repo.AddBadgeToDic(badge); yesNo = false; addMoreDoors = false; break; default: Console.WriteLine("\n\t Yes or No?"); break; } } } else { Console.WriteLine($"\n\t That is not a valid option. Please enter a number 1-8"); Console.ReadLine(); Console.Clear(); } } Console.WriteLine($"\n\t Badge {badge.BadgeID} has been created and has access to these Doors:"); ShowDoors(badge); Console.ReadKey(); }