Esempio n. 1
0
        public void RemoveBadge()
        {
            // Arrange
            Badges badge = new Badges(0711, new List <string> {
                "D4, F5"
            });

            // Act
            bool removeDoor = _repo.RemoveDoorsFromExistingBadge(0711, new List <string> {
                "D4, F5}"
            });

            // Assert
            Assert.IsTrue(removeDoor);
        }
Esempio n. 2
0
        // Edit a badge
        private void EditExistingBadge()
        {
            // Display all badges method here?


            Badges updateBadge = new Badges();

            // Prompt user for badge number
            Console.WriteLine("Enter the badge ID to update:");
            string badgeIDAsString = Console.ReadLine();

            updateBadge.BadgeID = int.Parse(badgeIDAsString);

            // Tell user what doors badge has access to through helper method
            List <string> doors      = _badgesRepo.GetListOfDoors(updateBadge.BadgeID);
            string        doorAccess = String.Join(",", doors);

            Console.WriteLine($"{updateBadge.BadgeID} has access to {doorAccess}");

            // Ask user what they would like to do
            Console.WriteLine("What would you like to do?\n" +
                              "1. Update doors\n" +
                              "2. Remove all doors");

            string input = Console.ReadLine();

            // Evaluate user's input and act accordingly
            switch (input)
            {
            case "1":
                //Update All Doors
                Badges newDoors = new Badges();
                Console.WriteLine("Enter the new list of doors.");
                newDoors.ListOfDoorNames.Add(Console.ReadLine());
                _badgesRepo.UpdateDoorsOnExistingBadge(updateBadge.BadgeID, newDoors.ListOfDoorNames);

                // Tell user what doors badge has access to through helper method
                List <string> newListOfDoors = _badgesRepo.GetListOfDoors(updateBadge.BadgeID);
                string        newDoorAccess  = String.Join(",", newListOfDoors);


                Console.WriteLine($"{updateBadge.BadgeID} has access to {newDoorAccess}");
                break;

            case "2":
                // Remove All doors
                Console.WriteLine("Are you sure you want to remove all doors (y/n)?");
                string removeDoors = Console.ReadLine().ToLower();
                if (removeDoors == "y")
                {
                    _badgesRepo.RemoveDoorsFromExistingBadge(updateBadge.BadgeID, updateBadge.ListOfDoorNames);
                    Console.WriteLine($"All doors removed from {updateBadge.BadgeID}.");
                    Console.WriteLine("Press any key to continue....");
                    Console.ReadLine();
                }
                Console.Clear();
                Menu();
                break;

            default:
                Console.WriteLine("Please enter a valid option.");
                break;
            }
            Console.WriteLine("Please press any key to continue...");
            Console.ReadLine();
            Console.Clear();
        }