public void AddTeam(long id, string name, DateTime createDate, string mainShirtColor, string secondaryShirtColor) { if (_soccerTeams.ContainsKey(id)) { throw new UniqueIdentifierException($"Já existe um time com o ID '{id}'."); } else { var newTeam = new SoccerTeam(id, name, createDate, mainShirtColor, secondaryShirtColor); _soccerTeams.Add(id, newTeam); } }
public string GetTeamName(long teamId) { SoccerTeam team = null; listSoccerTeam.TryGetValue(teamId, out team); if (team == null) { throw new TeamNotFoundException(); } return(team.name); }
public void SetCaptain(long playerId) { SoccerPlayer soccerPlayer = null; listSoccerPlayer.TryGetValue(playerId, out soccerPlayer); if (soccerPlayer == null) { throw new PlayerNotFoundException(); } SoccerTeam soccerTeam = null; listSoccerTeam.TryGetValue(soccerPlayer.teamId, out soccerTeam); soccerTeam.captainPlayerId = playerId; }
public string GetVisitorShirtColor(long teamId, long visitorTeamId) { if (!this.ExistsTeam(teamId)) { throw new TeamNotFoundException($"Time {teamId} não foi encontrado!"); } if (!this.ExistsTeam(visitorTeamId)) { throw new TeamNotFoundException($"Time {visitorTeamId} não foi encontrado!"); } SoccerTeam team1 = this.FindSoccerTeam(teamId); SoccerTeam team2 = this.FindSoccerTeam(visitorTeamId); return(team1.PrimaryColor.Equals(team2.PrimaryColor) ? team2.SecondaryColor : team2.PrimaryColor); }
public long GetTeamCaptain(long teamId) { SoccerTeam soccerTeam = null; listSoccerTeam.TryGetValue(teamId, out soccerTeam); if (soccerTeam == null) { throw new TeamNotFoundException(); } if (soccerTeam.captainPlayerId == 0) { throw new CaptainNotFoundException(); } return(soccerTeam.captainPlayerId); }
public void AddTeam(long id, string name, DateTime createDate, string mainShirtColor, string secondaryShirtColor) { if (this.ExistsTeam(id)) { throw new UniqueIdentifierException($"O Time {id} - {name} já está registrado!"); } var newSoccerTeam = new SoccerTeam { CreatedAt = createDate, Id = id, Name = name, PrimaryColor = mainShirtColor, SecondaryColor = secondaryShirtColor }; this.teams.Add(newSoccerTeam); }
public string GetVisitorShirtColor(long teamId, long visitorTeamId) { SoccerTeam houseTeam = null; SoccerTeam visitorTeam = null; if (!listSoccerTeam.TryGetValue(teamId, out houseTeam) || !listSoccerTeam.TryGetValue(visitorTeamId, out visitorTeam)) { throw new TeamNotFoundException(); } if (houseTeam.corUniformePrincipal.Equals(visitorTeam.corUniformePrincipal)) { return(visitorTeam.corUniformeSecundario); } else { return(visitorTeam.corUniformePrincipal); } }