Пример #1
0
 private void DisplayTeam(DevTeam team, bool showMembers = false)
 {
     Console.WriteLine($"ID: {team.ID,-5}Name: {team.Name,-20}Number of Members: {team.Team.Count,5}");
     if (showMembers)
     {
         foreach (Developer dev in team.Team)
         {
             DisplayDeveloper(dev);
         }
     }
 }
        public bool AddDeveloperToTeam(int devTeamId, Developer Developer)
        {
            DevTeam team = GetTeamById(devTeamId);

            if (team != null)
            {
                team.Team.Add(Developer);
                return(true);
            }
            return(false);
        }
        //U
        public bool UpdateExistingTeam(int id, DevTeam newTeam)
        {
            DevTeam oldTeam = GetTeamById(id);

            if (oldTeam != null)
            {
                oldTeam.ID   = newTeam.ID;
                oldTeam.Name = newTeam.Name;
                oldTeam.Team = newTeam.Team;
                return(true);
            }
            return(false);
        }
        public bool AddDeveloperListToTeam(int devTeamId, List <Developer> devs)
        {
            DevTeam team = GetTeamById(devTeamId);

            if (team != null)
            {
                foreach (Developer dev in devs)
                {
                    team.Team.Add(dev);
                }
                return(true);
            }
            return(false);
        }
Пример #5
0
        private void RemoveTeam()
        {
            DevTeam devTeam = FindTeam();

            DisplayTeam(devTeam);
            Console.WriteLine("Are you sure you want to remove this team? (y/n)");
            string response = Console.ReadLine().ToLower();

            if (response == "y")
            {
                Console.WriteLine("Are you certain? (y/n)");
                response = Console.ReadLine().ToLower();
                if (response == "y")
                {
                    developerTeamRepo.RemoveDeveloperTeam(devTeam.ID);
                    Console.WriteLine("Team removed");
                }
            }
        }
        //D
        public bool RemoveDeveloperTeam(int devTeamId)
        {
            DevTeam team = GetTeamById(devTeamId);

            if (team != null)
            {
                int initialCount = devTeamList.Count;
                devTeamList.Remove(team);
                if (initialCount > devTeamList.Count)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #7
0
        private bool ModifyTeam()
        {
            Console.Clear();
            DevTeam team = FindTeam();

            if (team == null)
            {
                return(false);
            }
            int              oldId      = team.ID;
            string           oldName    = team.Name;
            List <Developer> oldMembers = team.Team;

            if (team != null)
            {
                int              newId      = 0;
                string           newName    = "";
                List <Developer> newMembers = new List <Developer>();
                bool             loopExiter = true;
                string           response   = null;
                if (team == null)
                {
                    return(false);
                }
                DisplayTeam(team, true);
                while (loopExiter)
                {
                    Console.WriteLine("New ID (n for no change):");
                    response = Console.ReadLine().ToLower();
                    if (response != "n")
                    {
                        try
                        {
                            newId      = int.Parse(response);
                            loopExiter = false;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Invalid Response");
                        }
                    }
                    else
                    {
                        newId = oldId;
                    }
                    loopExiter = false;
                }
                loopExiter = true;
                Console.Clear();
                DisplayTeam(team);
                while (loopExiter)
                {
                    Console.WriteLine("New name (n for no change):");
                    response = Console.ReadLine().ToLower();
                    if (response != "n")
                    {
                        try
                        {
                            newName    = response;
                            loopExiter = false;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Invalid Response");
                        }
                    }
                    else
                    {
                        newName = oldName;
                    }
                    loopExiter = false;
                }
                loopExiter = true;
                Console.Clear();
                DisplayTeam(newId, newName, newMembers, true);
                Console.WriteLine("Is this correct? (y/n)");
                string answer = Console.ReadLine().ToLower();
                if (answer == "y")
                {
                    developerTeamRepo.UpdateExistingTeam(oldId, new DevTeam()
                    {
                        Name = newName, ID = newId, Team = newMembers
                    });
                }
                else if (answer == "n")
                {
                    ModifyTeam();
                }
            }
            return(false);
        }
 //C
 public void AddDeveloperTeam(DevTeam team)
 {
     devTeamList.Add(team);
 }