Example #1
0
        public void UpdateBadges()
        {
            ViewAllBadges();

            Console.WriteLine("Enter the badge's ID number you would like to update");

            int oldBadgeId = int.Parse(Console.ReadLine());

            Badges newBadge = new Badges();

            bool addingDoors = true;

            while (addingDoors)
            {
                Console.WriteLine("Press 1 to add another door, Press 2 to remove all doors, Press 3 to be done...");

                var userInput = Console.ReadLine();
                switch (userInput)
                {
                case "1":
                    Console.WriteLine("Please enter another door...");
                    listOfDoors.Add(Console.ReadLine());
                    break;

                case "2":
                    Console.WriteLine("All doors have been deleted");
                    listOfDoors.Clear();
                    break;

                case "3":
                    newBadge.ListOfDoors = listOfDoors;
                    _badgesRepo.UpdateBadges(_dictionary, oldBadgeId, newBadge.ListOfDoors);
                    addingDoors = false;
                    break;

                default:
                    Console.WriteLine("Press 1, 2, 3...");
                    Console.ReadKey();
                    break;
                }
            }
            bool wasUpdated = _badgesRepo.UpdateExistingBadges(oldBadgeId, newBadge);

            if (wasUpdated)
            {
                Console.WriteLine("Badge successfully updated");
            }
            else
            {
                Console.WriteLine("Could not update badge");
            }
        }