public void AddADoor() { Console.WriteLine("Enter the badge key to select a badge you would like to add a door to."); //this is the inside of ListAllBadges //foreach (KeyValuePair<int, BadgesPOCOs> badge in _badgeRepo.ViewAllBadges()) //{ // DisplayBadgeDetails(badge); //} ListAllBadges(); int userBadgeKey = int.Parse(Console.ReadLine()); BadgesPOCOs addingADoor = new BadgesPOCOs(); Setup(addingADoor); bool isSuccessful = _badgeRepo.AddingDoor(userBadgeKey, addingADoor.DoorAccess); if (isSuccessful) { Console.WriteLine("Success"); } else { Console.WriteLine("Exiting to Menu"); } Console.ReadKey(); }
//i was unable to get this part finished. I have a remove all method but couldn't get the removal of a single door to work. //public void RemoveADoor() //{ // Console.WriteLine("Enter the badge key to select a badge to remove a door from."); // //this is the inside of ListAllBadges // //foreach (KeyValuePair<int, BadgesPOCOs> badge in _badgeRepo.ViewAllBadges()) // //{ // // DisplayBadgeDetails(badge); // //} // ListAllBadges(); // int userKeyInput = int.Parse(Console.ReadLine()); // BadgesPOCOs newBadge = new BadgesPOCOs(); // //Doesn't work but retyped this from the Setup method in order to display the doors but have a different WriteLine ontop of the door list to choose from // // // bool userInputDoorAccess = false; // while (!userInputDoorAccess) // { // Console.WriteLine("Are you sure you want to remove a door? (y/n)"); // string userInputAddDoors = Console.ReadLine().ToLower(); // if (userInputAddDoors == "y") // { // Console.WriteLine("Input the door you would like to REMOVE\n" + // "1. A1\n" + // "2. A2\n" + // "3. A3\n" + // "4. A4\n" + // "5. A5\n" + // "6. B1\n" + // "7. B2\n" + // "8. B3\n" + // "9. B4\n" + // "10. B5"); // string userInputNewDoors = Console.ReadLine(); // switch (userInputNewDoors) // { // case "1": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "2": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "3": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "4": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "5": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "6": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "7": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "8": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "9": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // case "10": // newBadge.DoorAccess.Add((DoorAccess)int.Parse(userInputNewDoors)); // break; // default: // break; // } // } // else // { // userInputDoorAccess = true; // } // } // BadgesPOCOs removingADoor = new BadgesPOCOs(); // bool isSuccessful = _badgeRepo.RemoveADoor(userKeyInput, removingADoor.DoorAccess); // if (isSuccessful) // { // Console.WriteLine("Door removed"); // } // else // { // Console.WriteLine("Removal Failed"); // } //} public void RemoveAllDoors() { //found this by accident kind of.. REMOVES ALL DOORS Could be useful so will keep it in the UI and do another method for deleting a specific door //i believe it will require a mixture of the update method and the adding method with a tweak Console.WriteLine("Enter the badge key to remove all doors off that badge."); //this is the inside of ListAllBadges //foreach (KeyValuePair<int, BadgesPOCOs> badge in _badgeRepo.ViewAllBadges()) //{ // DisplayBadgeDetails(badge); //} ListAllBadges(); int userBadgeKey = int.Parse(Console.ReadLine()); BadgesPOCOs removingAllDoors = new BadgesPOCOs(); bool isSuccessful = _badgeRepo.RemovingAllDoors(userBadgeKey, removingAllDoors.DoorAccess); if (isSuccessful) { Console.WriteLine("Success"); } else { Console.WriteLine("Exiting to Menu"); } Console.ReadKey(); }
public void UpdateBadge() { BadgesPOCOs newContent = new BadgesPOCOs(12345, new List <DoorAccess> { DoorAccess.A3, DoorAccess.A5 }); bool updateResult = _repo.UpdateBadge(1, newContent); Assert.IsTrue(updateResult); }
public void Arrange() { _repo = new BadgesRepo(); _content = new BadgesPOCOs(12345, new List <DoorAccess> { DoorAccess.A3, DoorAccess.A5 }); _repo.AddNewBadge(_content); }
public void AddNewBadge() { BadgesPOCOs content = new BadgesPOCOs(); BadgesRepo repository = new BadgesRepo(); bool addResult = repository.AddNewBadge(content); Assert.IsTrue(addResult); }
private void UpdateBadge() { Console.Clear(); Console.WriteLine("Which badge would you like to update? Please enter the Key."); //this is the inside of ListAllBadges //foreach (KeyValuePair<int, BadgesPOCOs> badge in _badgeRepo.ViewAllBadges()) //{ // DisplayBadgeDetails(badge); //} ListAllBadges(); int userInputBadgeKey = int.Parse(Console.ReadLine()); Console.ReadKey(); BadgesPOCOs newBadgeData = new BadgesPOCOs(); Console.WriteLine("Please enter a new Badge ID:"); int userInputBadgeID = int.Parse(Console.ReadLine()); newBadgeData.BadgeID = userInputBadgeID; Setup(newBadgeData); bool isSuccessful = _badgeRepo.UpdateBadge(userInputBadgeKey, newBadgeData); if (isSuccessful) { Console.WriteLine("Success"); } else { Console.WriteLine("Exiting to Menu"); } Console.ReadKey(); }
public void GetBadgesByKey() { BadgesPOCOs searchResult = _repo.GetBadgesByKey(1); Assert.AreEqual(_content, searchResult); }