public void AddBadge(Badge badge) { badges.Add(badge.BadgeID, badge); badgeNumbers.Add(badge.BadgeID); }
public void RemoveBadge(Badge b) { badges.Remove(b.BadgeID); badgeNumbers.Remove(b.BadgeID); }
//This is where I got lost for updating the doors. Really lost for replacing only the value part of a dictionary. SOS public void AddDoorToBadge(Badge badge, string door) { var newDoorList = _badgeDictionary[badge.BadgeID]; }
public void AddBadgeToDictionary(Badge badge) { _dictionaryOfBadges[badge.BadgeID] = badge.Door; }
public void NewBadge(Badge badge) { _badgePairs.Add(badge.BadgeID, badge.Door); }
public void AddBadgeToDictionary(Badge badge) { BadgeID.Add(badge.BadgeNum, badge.DoorList); }
public void Run() { Badge One = new Badge { BadgeId = 1, DoorNames = new List <string>() { "a1", "a5", "d4" } }; Badge Two = new Badge { BadgeId = 2, DoorNames = new List <string>() { "a1", "a4", "b1", "b2" } }; Badge Three = new Badge { BadgeId = 3, DoorNames = new List <string>() { "a4", "a5" } }; _badgeRepo.AddBadgeToList(One); _badgeRepo.AddBadgeToList(Two); _badgeRepo.AddBadgeToList(Three); bool isRunning = true; while (isRunning) { Console.WriteLine("What would you like to do?\n\t1. Create a new badge.\n\t2. " + "Update doors on an existing badge.\n\t3. Delete a badge.\n\t4. Show a list" + " with badge numbers and door access.\n\t5. Exit."); int reply = int.Parse(Console.ReadLine()); switch (reply) { case 1: CreateNewBadge(); break; case 2: UpdateDoors(); break; case 3: DeleteBadge(); break; case 4: PrintList(); break; case 5: isRunning = false; break; default: Console.WriteLine("Invalid input."); break; } } }
public void UpdateBadgeInList(Badge info) { _badgePairedToDoors[info.BadgeId] = info.DoorNames; }
public void CreateBadge(int badgeNum, List <string> list) { Badge newBadge = new Badge(badgeNum, list); _badgeDictionary.Add(newBadge.BadgeID, newBadge.AccessList); }
public void UpdateDoors() { Console.WriteLine("Which badge # do you want to update?"); var id = int.Parse(Console.ReadLine()); Dictionary <int, List <string> > badges = _badgeRepo.ShowList(); List <string> doors = badges[id]; bool isRunning = true; while (isRunning) { Console.WriteLine("Do you want to remove a door from this badge? y/n"); string answer = Console.ReadLine(); if (answer == "y") { Console.WriteLine("Enter the door that this badge can no longer access: "); var door = Console.ReadLine(); doors.Remove(door); } else { break; } Console.WriteLine("Do you want to remove another door? y/n"); var reply = Console.ReadLine(); if (reply == "y") { isRunning = true; Console.WriteLine("Enter another door that this badge can no longer access:"); var doorTwo = Console.ReadLine(); doors.Remove(doorTwo); } else { isRunning = false; break; } } bool isRunningTwo = true; while (isRunningTwo) { Console.WriteLine("Do you want to add a door to this badge? y/n"); var replyTwo = Console.ReadLine(); if (replyTwo == "y") { Console.WriteLine("Enter the door that this badge can access: "); var doorThree = Console.ReadLine(); doors.Add(doorThree); } else { isRunningTwo = false; break; } Console.WriteLine("Do you want to add another door? y/n"); var replyThree = Console.ReadLine(); if (replyThree == "y") { isRunningTwo = true; Console.WriteLine("Enter another door that this badge can access:"); var doorTwo = Console.ReadLine(); doors.Add(doorTwo); } else { isRunningTwo = false; break; } } Badge newBadge = new Badge(id, doors); _badgeRepo.UpdateBadgeInList(newBadge); }
public void Run() { Badge badgeOne = new Badge { BadgeID = 1, DoorAccess = new List <string>() { "A1", "C4", "D2" } }; Badge badgeTwo = new Badge { BadgeID = 2, DoorAccess = new List <string>() { "A1", "C2", "C3" } }; Badge badgeThree = new Badge { BadgeID = 3, DoorAccess = new List <string>() { "A2", "B1", "B3", "D1" } }; badgeRepo.AddBadgeToList(badgeOne); badgeRepo.AddBadgeToList(badgeTwo); badgeRepo.AddBadgeToList(badgeThree); bool isRunning = true; while (isRunning) { Console.WriteLine("What would you like to do?\n\t" + "1. Create New Badge\n\t" + "2. Update Existing Badge\n\t" + "3. Delete Existing Badge\n\t" + "4. View Badge Access List\n\t" + "5. Exit"); int input = badgeRepo.ParseResponseToInt(); switch (input) { case 1: CreateNewBadge(); break; case 2: UpdateExistingBadge(); break; case 3: DeleteBadgeID(); break; case 4: ViewBadgeAccessList(); break; case 5: isRunning = false; break; default: break; } } }
public void Run() { while (isRunning) { int badgeID; string input = Menu(); Dictionary <int, List <string> > badges = badgeRepo.GetBadges(); switch (input) { case "1": List <string> doorValue = new List <string>(); Console.WriteLine("\nWhat is the badge identification number?:"); badgeID = int.Parse(Console.ReadLine()); bool doorList = true; while (doorList) { Console.WriteLine("\nList a door that it needs access to:"); doorValue.Add(Console.ReadLine()); bool doorLoop = true; while (doorLoop) { Console.WriteLine("\nAny other doors(y/n)?"); string doorInput = Console.ReadLine(); switch (doorInput) { case "y": doorLoop = false; doorList = true; Console.Clear(); break; case "n": doorLoop = false; doorList = false; Badge badge = new Badge(badgeID, doorValue); badgeRepo.NewBadge(badge); Console.Clear(); break; default: doorLoop = true; Console.Clear(); break; } } } break; case "2": Console.WriteLine("What is the ID of the badge you'd like to update?"); badgeID = int.Parse(Console.ReadLine()); if (badges.Keys.Contains(badgeID)) { bool keyLoop = true; while (keyLoop) { Console.WriteLine($"\nBadge {badgeID} can access the following doors: "); badges[badgeID].ForEach(i => Console.Write($"{i}, ")); Console.WriteLine("\n\nWhat would you like to do?\n" + "1. Remove door\n" + "2. Add door\n" + "3. Cancel\n"); string doorInput = Console.ReadLine(); switch (doorInput) { case "1": keyLoop = false; Console.WriteLine("\nSelect a door to remove."); string remove = Console.ReadLine(); badges[badgeID].Remove(remove); Console.Clear(); break; case "2": keyLoop = false; Console.WriteLine("\nAdd a door number for access"); string add = Console.ReadLine(); badges[badgeID].Add(add); Console.Clear(); break; case "3": keyLoop = false; Console.Clear(); break; default: Console.Clear(); break; } } break; } break; case "3": Console.WriteLine("\nBadgeID\t\tDoorAccess\n"); foreach (int id in badges.Keys) { string listDoor = ""; foreach (string door in badges[id]) { listDoor += door + "\t"; } Console.WriteLine($"{id}\t\t{listDoor}"); } break; case "4": isRunning = false; break; default: break; } } }
public void AddBadge(Badge badge) { _badgeID.Add(badge.BadgeNum, badge.Doors); }
public void AddBadge(Badge content) { dictOfBadges.Add(content.BadgeID, content.DoorName); }
public void Run() { while (loop) { int badgeID; string input = ConsoleMenu(); Dictionary <int, List <string> > badges = _badgeRepo.GetBadges(); switch (input) { case "1": bool y = true; List <string> doorValue = new List <string>(); Console.WriteLine("\nWhat is the number on the badge:"); badgeID = int.Parse(Console.ReadLine()); while (y) { Console.WriteLine("\nList a door that it needs access to:"); doorValue.Add(Console.ReadLine()); bool looping = true; while (looping) { Console.WriteLine("\nAny other doors(y/n)?"); System.ConsoleKeyInfo ans = Console.ReadKey(); string answer = ans.KeyChar.ToString(); switch (answer) { case "y": looping = false; y = true; Console.Clear(); break; case "n": looping = false; y = false; Badge badge = new Badge(badgeID, doorValue); _badgeRepo.NewBadge(badge); Console.Clear(); break; default: looping = true; Console.Clear(); break; } } } break; case "2": Console.WriteLine("\nWhat is the badge number to update?"); badgeID = int.Parse(Console.ReadLine()); if (badges.Keys.Contains(badgeID)) { bool t = true; while (t) { Console.WriteLine($"\nBadge number {badgeID} has acsess to doors: "); badges[badgeID].ForEach(i => Console.Write("\t{0}", i)); Console.WriteLine("\n\nWhat would you like to do?\n" + "[1] Remove a door\n" + "[2] Add a door\n" + "[3] Cancel\n"); System.ConsoleKeyInfo pushed = Console.ReadKey(); string push = pushed.KeyChar.ToString(); switch (push) { case "1": t = false; Console.WriteLine("\nWhich door would you like to remove?"); string remove = Console.ReadLine(); badges[badgeID].Remove(remove); Console.Clear(); break; case "2": t = false; Console.WriteLine("\nWhich door would you like to add?"); string add = Console.ReadLine(); badges[badgeID].Add(add); Console.Clear(); break; case "3": t = false; Console.Clear(); break; default: Console.Clear(); break; } } break; } break; case "3": Console.WriteLine("\nBadge#\t\tDoorAccess\n"); foreach (int id in badges.Keys) { string listDoor = ""; foreach (string door in badges[id]) { listDoor += door + "\t"; } Console.WriteLine($"{id}\t\t{listDoor}"); } break; case "X": loop = false; break; default: break; } } }
public void AddBadgeToList(Badge info) { _badgePairedToDoors.Add(info.BadgeId, info.DoorNames); }
public void AddBadgeToList(Badge badge) { _badgeList.Add(badge.BadgeID, badge.DoorsAccessible); }
public BadgeEditScreen(Badge b) { this.badge = b; }
public void AddBadgeIDToList(Badge badge) { _badgeRepo.Add(badge.BadgeID, badge.DoorNames); }
public void AddDoortoList(Badge doors) { _Doors.Add(); }
public void UpdateBadgeID(Badge badge) { _badgeRepo[badge.BadgeID] = badge.DoorNames; }
static void Main(string[] args) { Badge badge = new Badge(); BadgeRepository badgeRepo = new BadgeRepository(); Dictionary <int, List <string> > BadgeID = badgeRepo.GetDictionary(); List <string> listOne = new List <string>(); listOne.Add("A1"); listOne.Add("A2"); Badge one = new Badge(123, listOne); string response = null; while (response != "4") { Console.WriteLine($"Hello Security Admin!\n\nWhat would you like to do?\n\n1. Add a badge\n2. Edit a badge\n3. List all badges\n4. Exit program\n"); response = Console.ReadLine(); Console.Clear(); if (response == "1") { Console.WriteLine("Enter badge ID number:"); badge.BadgeNum = Int32.Parse(Console.ReadLine()); List <String> _newDoorsFromConsole = new List <string>(); bool doorAddLoop = true; while (doorAddLoop) { Console.WriteLine("Assign new door: (A5, B3, C2, ect.)"); var newDoor = Console.ReadLine(); _newDoorsFromConsole.Add(newDoor); Console.WriteLine("Would you like to add another door? y/n"); var addDoorResponse = Console.ReadLine(); if (addDoorResponse == "n") { doorAddLoop = false; } } badge.DoorList = _newDoorsFromConsole; badgeRepo.AddBadgeToDictionary(badge); Console.Clear(); } if (response == "2") { Console.WriteLine("Which badge would you like to edit?"); var desiredKey = Int32.Parse(Console.ReadLine()); List <string> newDoorList = BadgeID[desiredKey]; var doorString = badgeRepo.ListToString(newDoorList); Console.WriteLine($"\nBadge: {desiredKey} has access to doors {doorString}\n"); Console.WriteLine($"What would you like to change?\n\t1. Remove a door\n\t2. Add a door\n\t3. Change nothing"); var updateResponse = Int32.Parse(Console.ReadLine()); if (updateResponse == 1) { Console.WriteLine($"Badge: {desiredKey} has access to doors {doorString}\n\n"); string removeResponse = "y"; while (removeResponse != "n") { Console.WriteLine("Which door would you like to remove?"); var removeDoor = Console.ReadLine(); newDoorList.Remove(removeDoor); Console.WriteLine("Would you like to remove another door? y/n"); removeResponse = Console.ReadLine(); } } else { while (updateResponse == 2) { Console.WriteLine("Enter door to be added."); var newDoor = Console.ReadLine(); newDoorList.Add(newDoor); Console.WriteLine("Would you like to add another door? y/n"); var newDoorResponse = Console.ReadLine(); if (newDoorResponse == "y") { updateResponse = 2; } else { updateResponse = 4; } } } Console.Clear(); } if (response == "3") { Console.WriteLine($"Here is a list of current badges: \n\nBadge ID number\t\tDoor Access\n"); foreach (KeyValuePair <int, List <string> > newBadgeID in BadgeID) { var doorString = badgeRepo.ListToString(newBadgeID.Value); Console.WriteLine($"{newBadgeID.Key}\t\t{doorString}"); } Console.WriteLine("Prese 'enter' to return to main menu."); Console.ReadLine(); Console.Clear(); } if (response == "4") { break; } } }
public void AddBadgeToDictionary(Badge badge) { _badgeDictionary.Add(badge.BadgeID, badge.Door); }