Пример #1
0
        public void SeedContent()
        {
            /*Add a badge
             * What is the number on the badge: 12345
             *
             * List a door that it needs access to: A5
             *
             * Any other doors(y/n)? y
             *
             * List a door that it needs access to: A7
             *
             * Any other doors(y/n)? n
             *
             * (Return to main menu.)*/
            Badges firstbadge = new Badges();

            firstbadge.ID = 12345;
            Doors firstDoor = new Doors();

            firstDoor.Door = "Door A5";
            Doors secondDoor = new Doors();

            secondDoor.Door = "Door A7";
            List <Doors> doors = new List <Doors>()
            {
                firstDoor, secondDoor
            };

            firstbadge.Door = doors;
        }
Пример #2
0
        public void UdateBadge(int id, Badges newBadge)
        {
            Badges oldBadge = GetBadgeForUpdate(id);

            if (oldBadge != null)
            {
                oldBadge.Door = newBadge.Door;
            }
        }
Пример #3
0
        public bool BadgeAddedToDirectory(Badges badge)
        {
            int startingCount = _BadgesDirectory.Count;

            _BadgesDirectory.Add(_BadgesDirectory.Count + 1, badge);

            bool wasAdded = (_BadgesDirectory.Count > startingCount);

            return(wasAdded);
        }
Пример #4
0
 public Badges GetBadgeForUpdate(int id)
 {
     foreach (int key in _BadgesDirectory.Keys)
     {
         Badges badges = _BadgesDirectory[key];
         if (badges.ID == id)
         {
             return(badges);
         }
     }
     return(null);
 }
Пример #5
0
        public void EditBadge()
        {
            Console.Clear();
            Console.WriteLine("What Badge ID would you like to update?");
            int id = int.Parse(Console.ReadLine());

            _repo.GetBadgeForUpdate(id);
            DoorEase();
            Badges newBadge = new Badges();

            _repo.UdateBadge(id, newBadge);
            Console.WriteLine($"Badge {id} has been updated.");
        }
Пример #6
0
        public void AddBadge()
        {
            Console.Clear();
            Console.WriteLine("What is the Employee's Badge ID?");
            int id = int.Parse(Console.ReadLine());

            DoorEase();
            Badges newbadge      = new Badges(id, doorsList);
            bool   badgeWasAdded = _repo.BadgeAddedToDirectory(newbadge);

            if (badgeWasAdded)
            {
                Console.WriteLine($"Badge {id} was added.");
            }
            else
            {
                Console.WriteLine("Badge was not added to the system.");
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }