public HandsOverviewViewModel(List <HandHistory> hh, string playerName, Filter filter, PaginationSettings pagination) { this.Pagination = pagination; this.Hands = hh; this.Filters = filter; if (this.Filters.OrderByHeroEarnings == "Losses") { // TODO: Flatten these hand models, we know what player we're looking for, no need to have to linq my way to get everything this.Hands = hh.Where(x => x.PlayerHandHistories.Exists(y => y.PlayerName == playerName)).OrderBy(x => Math.Abs(x.PlayerHandHistories.SingleOrDefault(y => y.PlayerName == playerName).Earnings)).Reverse().ToList(); } this.Hands.Take(this.Pagination.PageSize); }
public PlayersOverviewViewModel(List <HandHistory> hh, PaginationSettings pagination) { this.Pagination = pagination; Dictionary <string, int> stats = new Dictionary <string, int>(); foreach (HandHistory handHistory in hh) { foreach (PlayerHandHistory phh in handHistory.PlayerHandHistories) { if (!stats.ContainsKey(phh.PlayerName)) { stats.Add(phh.PlayerName, 0); } stats[phh.PlayerName]++; } } foreach (string player in stats.Keys) { Players.Add(new PlayerOverviewStats(player, stats[player])); } this.Players = this.Players.OrderByDescending(x => x.HandCount).ToList(); }