//DevTeam Method (Get TeamId and assign a developer to that team public void AddDeveloperToTeam(int devTeamId, int developerId) { //using helper method to obtain devTeam var devTeam = GetDevTeamById(devTeamId); //check to see if we have a team if (devTeam != null) { //using helper method inside of the developer repository to get a //speciffic developer. var developer = _developerRepo.GetDeveloperById(developerId); //check to see if a developer exist if (developer != null) { //if the developer exist add the developer and add //the developer to the dev team devTeam.Developers.Add(developer); } else { //the developer doesn't exist Console.WriteLine($"Sorry there is no Developer with id: {developerId}"); } } else { //the devTeam doesn't exist Console.WriteLine($"Sorry there is no DevTeam with id: {devTeamId}"); Console.WriteLine(); } }
//Another method called DeleteDevFromTeam() public bool DeleteDevFromTeam(int Id, int teamid) { DeveloperRepo Repo = new DeveloperRepo(); Developer developer = Repo.GetDeveloperById(Id); if (developer == null) { return(false); } int initialcount = _devTeams.Count; //_devTeams.Remove(); //find the team that I want to delete a dev from use the team id and item id foreach (var item in _devTeams) { if (teamid == item.Id) { item.listOfDevelopers.Remove(developer); } } return(true); }