Ejemplo n.º 1
0
        private static void AddMatch(int id,string homeTeam, string awayTeam, int homeGoals,
            int awayteamGoals )
        {
            if (League.Matches.Any(p => p.ID == id))
            {
                throw new ArgumentException("Тоя мач сме го играли вече, дай друг.");
            }

            if (League.Teams.All(team => team.Name != homeTeam))
            {
                throw new InvalidOperationException("Home team not found");
            }

            if (League.Teams.All(teamGuest => teamGuest.Name != awayTeam))
            {
                throw new InvalidOperationException("Away team not found");
            }

            var currentHomeTeam = League.Teams.First(team => team.Name == homeTeam);
            var currentAwayTeam = League.Teams.First(team => team.Name == awayTeam);
            var currentScore = new Scores(homeGoals, awayteamGoals);
            var currentMatch = new Matches(id, currentHomeTeam, currentAwayTeam, currentScore );
            League.AddMatches(currentMatch);

            Console.WriteLine($"Match *{currentMatch.HomeTeam.Name} VS {currentMatch.AwayTeam.Name}* added");
        }
Ejemplo n.º 2
0
        public static void AddMatches(Matches match)
        {
            if (CheckIfMatchExists(match))
            {
                throw new ArgumentException("Match with the same match ID already exists");
            }

            matches.Add(match);
        }
Ejemplo n.º 3
0
 private static bool CheckIfMatchExists(Matches match)
 {
     return matches.Any(p => p.ID == match.ID);
 }