Exemple #1
0
        //Methods for DevTeam
        //Create a New Team
        private void CreateTeam()
        {
            Console.Clear();
            DevTeam team = new DevTeam();

            //Get Name
            Console.WriteLine("What is the name of the new team? ");
            team.TeamName = Console.ReadLine();
            //Get ID
            do
            {
                Console.WriteLine($"Enter the numerical Team ID for {team.TeamName}");
                string s = Console.ReadLine();

                int.TryParse(s, out int k);
                team.TeamID = k;
            } while (team.TeamID == 0);
            //Loop to add multiple Developers at one time
            int numOfDev;

            ViewDevelopers();
            do
            {
                Console.WriteLine($"How many developers would you like to add to {team.TeamName}?\n" +
                                  $"A minimum of 1 team member is required."); //had to include because what if user intentionally enters 0
                string s = Console.ReadLine();

                int.TryParse(s, out int k);
                numOfDev = k;
            } while (numOfDev == 0);
            if (numOfDev > _developerRepo._listOfDevelopers.Count)
            {
                Console.WriteLine($"{numOfDev} is greater than the number of available developers.  Please try again.");
                Menu();
            }
            List <Developer> newList = new List <Developer>(numOfDev);

            for (int i = 0; i < numOfDev; i++)
            {
                Console.WriteLine($"Enter the badge number of the next developer you wish to add to {team.TeamName}: ");
                int id = int.Parse(Console.ReadLine());

                foreach (Developer dev in _developerRepo._listOfDevelopers)    //code to also add this team to the developer object
                {
                    if (id == dev.BadgeNumber)
                    {
                        dev.Team = team;
                    }
                }

                newList.Add(_developerRepo.GetDeveloper(id));
            }
            team.TeamMembers = newList;
            _devTeamRepo.CreateNewTeam(team);
        }///View List of teams