Esempio n. 1
0
        public void AddBadge()
        {
            // creating working list of doors
            List <string> _doorsToAdd = new List <string>();
            // invoke the helper to get a valid int
            int newBadgeNumber = InputIntHelper("\n What is the number on the badge:", "\nEnter an Integer badge Number.");

            // test badgeID for uniqueness
            if (Badges.BadgeNumberIsUnique(newBadgeNumber))
            {
                // Get doors into a list of strings
                bool   active = true;
                string addMore;
                while (active)
                {
                    Console.WriteLine("\nList a door that it needs access to:");
                    _doorsToAdd.Add(Console.ReadLine());
                    Console.WriteLine("\nAny other doors (y/n)?");
                    addMore = Console.ReadLine();
                    if (addMore.ToLower() != "y")
                    {
                        active = false;
                    }
                }
                // call repo, will return true is successful
                if (Badges.AddBadge(newBadgeNumber, _doorsToAdd))
                {
                    Console.WriteLine("Door added.");
                }
                else
                {
                    Console.WriteLine("Door not added.");
                }
            }
            else
            {
                Console.WriteLine("New badge number must be unique.");
            }
        }