public static void AddMatches(Match match) { if (CheckMatchExists(match)) { matches.Add(match); } }
public static void AddMatch(Match match) { if (MatchAddCheck(match)) { throw new InvalidOperationException("Match already exists in the league!"); } Matches.Add(match); }
public static void AddMatches(Match match) { if (AddMatchesChecker(match)) { throw new InvalidOperationException("Match already exists in the league."); } matches.Add(match); }
private static bool CheckMatchExists(Match match) { if (matches.Any(m => m.Id == match.Id)) { return false; } return true; }
private static void AddMatch(int id, string homeTeamName, string awayTeamName, string score) { Team t = new Team(homeTeamName, " ", new DateTime(1850, 1, 1)); t.Name = homeTeamName; Team s = new Team(awayTeamName, " ", new DateTime(1850, 1, 1)); s.Name = awayTeamName; Score sc; string[] scc = score.Split(' '); sc = new Score(int.Parse(scc[0]), int.Parse(scc[1])); Match match = new Match(t, s, sc, id); if (League.CheckIfMatchExist(match)) { throw new InvalidOperationException("This match already exist"); } League.AddMatch(match); Console.WriteLine("Match - Confirmed"); }
private static void AddMatch(string homeTeamName, string awayTeamName, string idStr, string homeTeamGoals, string awayTeamGoals) { if (League.Teams.All(t => t.Name != homeTeamName)) { throw new InvalidOperationException("Team name"); } if (League.Teams.All(t => t.Name != awayTeamName)) { throw new InvalidOperationException("Team name"); } var homeTeam = League.Teams.First(t => t.Name == homeTeamName); var awayTeam = League.Teams.First(t => t.Name == awayTeamName); var id = int.Parse(idStr); var score = new Score(int.Parse(homeTeamGoals), int.Parse(awayTeamGoals)); var match = new Match(homeTeam, awayTeam, id, score); League.AddMatches(match); Console.WriteLine("Match with ID: " + idStr + " has been added succesfully"); }
private static bool MatchAddCheck(Match match) { return Matches.Any(m => m.Id == match.Id); }
public static bool AddMatchesChecker(Match match) { return Matches.Any(m => m.Id == match.Id); }