Exemplo n.º 1
0
        public static void AddMatch(Match currentMatch)
        {
            if (MatchExists(currentMatch))
            {
                throw new InvalidOperationException("Match already exists!");
            }

            matches.Add(currentMatch);
        }
Exemplo n.º 2
0
        private static void AddMatch(int currentID, string homeTeamName, string awayTeamName, int homeTeamScore, int awayTeamScore)
        {
            Team currentHomeTeam = League.Teams.FirstOrDefault(x => x.Name.Equals(homeTeamName));
            Team currentAwayTeam = League.Teams.FirstOrDefault(x => x.Name.Equals(awayTeamName));

            if (currentHomeTeam == null)
            {
                throw new InvalidOperationException("Home team does not exist in the league!");
            }

            if (currentAwayTeam == null)
            {
                throw new InvalidOperationException("Away team does not exist in the league!");
            }

            Match currentMatch = new Match(currentID, currentHomeTeam, currentAwayTeam, new Score(homeTeamScore, awayTeamScore));

            League.AddMatch(currentMatch);

            Console.WriteLine("Match successfully added!");
        }
Exemplo n.º 3
0
 private static bool MatchExists(Match currentMatch)
 {
     bool matchExists = Matches.Any(x => x.ID == currentMatch.ID);
     return matchExists;
 }