Beispiel #1
0
        //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();
        }
        //passes but unsure if correct
        public void RemovingAllDoors()
        {
            List <DoorAccess> newContent = new List <DoorAccess>(new List <DoorAccess> {
                DoorAccess.A3, DoorAccess.A5
            });
            bool removeResult = _repo.RemovingAllDoors(1, newContent);

            Assert.IsTrue(removeResult);
        }