private List <LeaderboardEntry> GetLeaderboardEntries(LeaderboardFilter filter, Leaderboard leaderboard) { var entries = leaderboard.Entries; if (leaderboard.Entries.Any()) { if (filter.Platform != "All") { entries = leaderboard.Entries .Where(l => l.Platform == filter.Platform).ToList(); } leaderboard.TotalEntries = entries.Count; entries = entries.Any() ? entries.Skip((filter.Page - 1) * filter.Count).Take(filter.Count).ToList() : new List <LeaderboardEntry>(); } return(entries); }
public Leaderboard GetLeaderboard(LeaderboardFilter filter) { var data = _repo.GetLeaderboards(); var result = new Leaderboard(); if (data.Any()) { if (filter.LeaderboardId > 0) { result = data .Where(l => l.LeaderboardId == filter.LeaderboardId).SingleOrDefault(); } if (result != null) { if (result.Entries != null) { result.Entries = GetLeaderboardEntries(filter, result); } } } return(result); }