public IHttpActionResult SaveMatch(List <Match> matches) { matches = matches.OrderBy(x => x.TimeStampUtc).ToList(); //Sat i AddMatch java foreach (var match in matches) { if (match.TimeStampUtc == DateTime.MinValue) { match.TimeStampUtc = DateTime.UtcNow; } LeaderboardView currentLeaderboard = _leaderboardService.GetLatestLeaderboardView(); _leaderboardService.AddMatchToLeaderboard(currentLeaderboard, match); _matchRepository.SaveMatch(match); _leaderboardViewRepository.SaveLeaderboardView(currentLeaderboard); } //TODO Run validation return(Ok()); }
public LeaderboardView RecalculateLeaderboard() { var matches = _matchRepository.GetMatches().OrderBy(x => x.TimeStampUtc); var leaderboardView = new LeaderboardView(); foreach (var match in matches) { AddMatchToLeaderboard(leaderboardView, match); _matchRepository.SaveMatch(match); } leaderboardView.Entries = leaderboardView.Entries.OrderByDescending(x => x.EloRating).ToList(); _leaderboardViewRepository.SaveLeaderboardView(leaderboardView); return(leaderboardView); }