diff --git a/src/Tournament.cs b/src/Tournament.cs index 03aff36..7c75970 100644 --- a/src/Tournament.cs +++ b/src/Tournament.cs @@ -25,31 +25,26 @@ public class Tournament public Tournament() { } - public Match GetMatch(int localMatchId) { - //return Matches.Where(m => m.LocalMatchId == localMatchId).First(); - throw new NotImplementedException(); + public Match? GetMatch(int localMatchId) { + return Matches.FirstOrDefault(m => m.LocalMatchId == localMatchId); } // // Find the next match - public Match GetNextMatch(int localMatchId) { - /* - var nextMatchId = Matches.Where(m => m.LocalMatchId == localMatchId).Select(m => m.WinProgression).FirstOrDefault(); - if (nextMatchId is null) { - return NotFound; - } else if (nextMatchId == -1) { - return NoMatch; - } */ - - /* + public Match? GetWinProgressionMatch(int localMatchId) { return Matches .Where(m => m.LocalMatchId == localMatchId) - .Select(m => m.WinProgression) - .First(); - */ - throw new NotImplementedException(); + .Select(m => Matches.FirstOrDefault(m2 => m2.LocalMatchId == m.WinProgression)) + .FirstOrDefault(); } + public Match? GetLoseProgressionMatch(int localMatchId) + { + return Matches.Where(m => m.LocalMatchId == localMatchId) + .Select(m => Matches.FirstOrDefault(m2 => m2.LocalMatchId == m.LoseProgression)) + .FirstOrDefault(); + } + // /* public Match GetNextMatch(int localMatchId, IOpponent opponent) =>