コード例 #1
0
        //Add badge

        public void AddNewBadgeToDict()
        {
            List <string> doorAccess = new List <string>();

            Console.WriteLine("Enter the Badge Id:");
            string badgeIdAsString = Console.ReadLine();
            int    badgeId         = int.Parse(badgeIdAsString);

            Console.WriteLine("Enter the name for this badge:");
            string badgeName = Console.ReadLine();


            Console.WriteLine("Enter the door that it needs access to:");
            string doorName = Console.ReadLine();

            doorAccess.Add(doorName);

            bool moreDoors = true;

            while (moreDoors)

            {
                Console.WriteLine("Any other Doors to be Added? Enter y or n");
                string input = Console.ReadLine();

                if (input == "y")
                {
                    Console.WriteLine("Enter the next door to access:");
                    string nextdoorName = Console.ReadLine();
                    doorAccess.Add(nextdoorName);
                }
                else
                {
                    moreDoors = false;
                    Console.WriteLine("Returning you to main menu\n" +
                                      "(Press any key to continue)");
                    Console.ReadKey();
                    Console.Clear();
                }
            }
            _repo.AddBadgeToDict(badgeId, new BadgeInfo(badgeId, doorAccess, badgeName));
        }