Example #1
0
        public void CreateNewBadge()
        {
            Console.Clear();

            int           badgeID = 0;
            List <string> doors   = new List <string>();

            Console.WriteLine("What is the badge number?");
            badgeID = int.Parse(Console.ReadLine());

            Console.WriteLine("What door would you like to give this badge access to?");
            string doorInput = Console.ReadLine();

            doors.Add(doorInput);

            bool running = true;

            while (running)
            {
                Console.Clear();

                Console.WriteLine("Would you like to add another door? (y/n)");
                string yesOrNo = Console.ReadLine();
                switch (yesOrNo)
                {
                case "y":
                    Console.WriteLine("What door would you like to give this badge access to?");
                    string doorInput2 = Console.ReadLine();
                    doors.Add(doorInput2);
                    break;

                case "n":
                    running = false;
                    break;
                }
            }
            Badge newBadge = new Badge(badgeID, doors);

            _badgeRepo.AddBadgeToList(newBadge);
        }
        public void Run()
        {
            Badge One = new Badge
            {
                BadgeId   = 1,
                DoorNames =
                    new List <string>()
                {
                    "a1", "a5", "d4"
                }
            };
            Badge Two = new Badge
            {
                BadgeId   = 2,
                DoorNames =
                    new List <string>()
                {
                    "a1", "a4", "b1", "b2"
                }
            };
            Badge Three = new Badge
            {
                BadgeId   = 3,
                DoorNames =
                    new List <string>()
                {
                    "a4", "a5"
                }
            };

            _badgeRepo.AddBadgeToList(One);
            _badgeRepo.AddBadgeToList(Two);
            _badgeRepo.AddBadgeToList(Three);
            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("What would you like to do?\n\t1. Create a new badge.\n\t2. " +
                                  "Update doors on an existing badge.\n\t3. Delete a badge.\n\t4. Show a list" +
                                  " with badge numbers and door access.\n\t5. Exit.");
                int reply = int.Parse(Console.ReadLine());
                switch (reply)
                {
                case 1:
                    CreateNewBadge();
                    break;

                case 2:
                    UpdateDoors();
                    break;

                case 3:
                    DeleteBadge();
                    break;

                case 4:
                    PrintList();
                    break;

                case 5:
                    isRunning = false;
                    break;

                default:
                    Console.WriteLine("Invalid input.");
                    break;
                }
            }
        }
        public void Run()
        {
            Badge badgeOne = new Badge {
                BadgeID = 1, DoorAccess = new List <string>()
                {
                    "A1", "C4", "D2"
                }
            };
            Badge badgeTwo = new Badge {
                BadgeID = 2, DoorAccess = new List <string>()
                {
                    "A1", "C2", "C3"
                }
            };
            Badge badgeThree = new Badge {
                BadgeID = 3, DoorAccess = new List <string>()
                {
                    "A2", "B1", "B3", "D1"
                }
            };

            badgeRepo.AddBadgeToList(badgeOne);
            badgeRepo.AddBadgeToList(badgeTwo);
            badgeRepo.AddBadgeToList(badgeThree);

            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("What would you like to do?\n\t" +
                                  "1. Create New Badge\n\t" +
                                  "2. Update Existing Badge\n\t" +
                                  "3. Delete Existing Badge\n\t" +
                                  "4. View Badge Access List\n\t" +
                                  "5. Exit");

                int input = badgeRepo.ParseResponseToInt();

                switch (input)
                {
                case 1:
                    CreateNewBadge();
                    break;

                case 2:
                    UpdateExistingBadge();
                    break;

                case 3:
                    DeleteBadgeID();
                    break;

                case 4:
                    ViewBadgeAccessList();
                    break;

                case 5:
                    isRunning = false;
                    break;

                default:
                    break;
                }
            }
        }