private void AddNewBadge() { Console.Clear(); Badge myBadge = new Badge(); List <Doors> doorList = new List <Doors>(); Doors access = new Doors(); Console.WriteLine("Enter Badge Number: "); myBadge.Id = Convert.ToInt32(Console.ReadLine()); bool keepThinking = true; while (keepThinking) { Console.Clear(); Console.WriteLine("Which doors would you like to add to this Badge \n" + "Level A: A1, A2, A3, A4 \n" + "Level B: B1, B2, B3, B4 \n" + "Type x and hit enter to exit Menu"); string userInput = Console.ReadLine(); switch (userInput) { case "A1": access.GetDoor1(); break; case "A2": access.GetDoor2(); break; case "A3": access.GetDoor3(); break; case "A4": access.GetDoor4(); break; case "B1": access.GetDoor5(); break; case "B2": access.GetDoor6(); break; case "B3": access.GetDoor7(); break; case "B4": access.GetDoor8(); break; case "x": keepThinking = false; break; default: Console.WriteLine("Invalid"); Console.ReadKey(); break; } } doorList.Add(access); myBadge.DoorsList = doorList; Console.WriteLine("Press any key to continue........."); Console.ReadKey(); _badgeRepo.AddBadge(myBadge); }
private void EditBadge() { Console.Clear(); Console.WriteLine("Type the ID# of the Badge you want to edit, then press enter"); Dictionary <int, List <Doors> > badges = _badgeRepo.GetBadges(); foreach (var id in badges) { Console.WriteLine($"Badge ID: {id.Key}"); } int userInput = Convert.ToInt32(Console.ReadLine()); foreach (var id in badges.Keys) { if (userInput == id) { badges.Remove(id); Console.Clear(); Badge myBadge = new Badge(); List <Doors> doorList = new List <Doors>(); Doors access = new Doors(); Console.WriteLine("Re-Enter Badge Number: "); myBadge.Id = Convert.ToInt32(Console.ReadLine()); bool keepThinking = true; while (keepThinking) { Console.Clear(); Console.WriteLine("Which doors would you like to add to this Badge \n" + "Level A: A1, A2, A3, A4 \n" + "Level B: B1, B2, B3, B4 \n" + "Type x and hit enter to exit Menu"); string userChoice = Console.ReadLine(); switch (userChoice) { case "A1": access.GetDoor1(); break; case "A2": access.GetDoor2(); break; case "A3": access.GetDoor3(); break; case "A4": access.GetDoor4(); break; case "B1": access.GetDoor5(); break; case "B2": access.GetDoor6(); break; case "B3": access.GetDoor7(); break; case "B4": access.GetDoor8(); break; case "x": keepThinking = false; break; default: Console.WriteLine("Invalid"); Console.ReadKey(); break; } } doorList.Add(access); myBadge.DoorsList = doorList; _badgeRepo.AddBadge(myBadge); break; } else { Console.WriteLine("Invalid"); } } Console.WriteLine("Press any key to continue........."); Console.ReadKey(); }