Example #1
0
        // Update existing developer
        private void UpdateExistingDeveloper()
        {
            // Display all developers
            DisplayAllDevelopers();

            // Ask for the DeveloperID of the developer to update
            Console.WriteLine("Enter the DeveloperID of the developer you'd like to update.");

            // Get that developer
            string    oldDevIDNumber = Console.ReadLine();
            Developer newDeveloper   = new Developer();

            newDeveloper.IDNumber = int.Parse(oldDevIDNumber);

            /*int idNumber, Developer newProgrammer*/

            // We will build a new object
            /*Developer newDeveloper = new Developer();*/

            // ID Number
            Console.WriteLine("Enter the ID Number of the developer.");
            string idNumber = Console.ReadLine();

            newDeveloper.IDNumber = int.Parse(idNumber);

            // First Name
            Console.WriteLine("Enter the developer's first name.");
            newDeveloper.DeveloperFirstName = Console.ReadLine();

            // Last Name
            Console.WriteLine("Enter the developer's last name.");
            newDeveloper.DeveloperLastName = Console.ReadLine();

            // PluralSight
            Console.WriteLine("Is this developer PluralSight licensed? (y/n)");
            string PluralSight = Console.ReadLine().ToLower();

            if (PluralSight == "y")
            {
                newDeveloper.PluralSight = true;
            }
            else
            {
                newDeveloper.PluralSight = false;
            }

            // Verify the update worked
            bool wasUpdated = _programmerRepo.UpdateExistingDeveloper(newDeveloper.IDNumber, newDeveloper);

            if (wasUpdated)
            {
                Console.WriteLine("Developer successfully updated!");
            }
            else
            {
                Console.WriteLine("Could not update develper.");
            }
        }