public string CreateStandingsTable(WowRealm _Realm, int _Count, Func <Player, bool> _RequirementLambda) { int pageIndex = PageUtility.GetQueryInt(Request, "page", 1) - 1;//Change range from 0 to * instead of 1 to * string commonTable = "<table id='characters-table' class='table'>"; commonTable += "<thead>" + PageUtility.CreatePlayerTableHeaderRow(Table_Standings_Columns) + "</thead>"; string hordeTable = commonTable + "<tbody>"; string allianceTable = commonTable + "<tbody>"; Func <KeyValuePair <string, Player>, double> sortLambda = (KeyValuePair <string, Player> player) => { double daysSinceLastSeen = (DateTime.UtcNow - player.Value.LastSeen).TotalDays; if (daysSinceLastSeen > 7) { return(int.MaxValue); } return((double)player.Value.Honor.LastWeekStanding + (daysSinceLastSeen / 10.0)); }; var playerArray = DatabaseAccess.GetRealmPlayers(this, _Realm, NotLoadedDecision.RedirectAndWait).OrderBy(sortLambda); DateTime lastRankUpdateDateUTC = StaticValues.CalculateLastRankUpdadeDateUTC(_Realm); int hordeCount = 0; int allianceCount = 0; foreach (var player in playerArray) { if ((player.Value.LastSeen - lastRankUpdateDateUTC).TotalHours > 0) { var playerFaction = StaticValues.GetFaction(player.Value.Character.Race); if (playerFaction == VF_RealmPlayersDatabase.PlayerFaction.Horde && hordeCount < (pageIndex + 1) * _Count && _RequirementLambda(player.Value) == true) { hordeCount++; if (hordeCount > pageIndex * _Count && hordeCount <= (pageIndex + 1) * _Count) { hordeTable += PageUtility.CreatePlayerRow(hordeCount, _Realm, player.Value, Table_Standings_Columns); } } else if (playerFaction == VF_RealmPlayersDatabase.PlayerFaction.Alliance && allianceCount < (pageIndex + 1) * _Count && _RequirementLambda(player.Value) == true) { allianceCount++; if (allianceCount > pageIndex * _Count && allianceCount <= (pageIndex + 1) * _Count) { allianceTable += PageUtility.CreatePlayerRow(allianceCount, _Realm, player.Value, Table_Standings_Columns); } } } if (hordeCount >= (pageIndex + 1) * _Count && allianceCount >= (pageIndex + 1) * _Count) { break; } } hordeTable += "</tbody></table>"; allianceTable += "</tbody></table>"; string pageTable = ""; pageTable += PageUtility.CreateDiv("span6", hordeTable); pageTable += PageUtility.CreateDiv("span6", allianceTable); pageTable = PageUtility.CreateDiv("row", pageTable); if ((hordeCount != 0 && hordeCount < pageIndex * _Count) && (allianceCount != 0 && allianceCount < pageIndex * _Count)) { pageIndex = (hordeCount - 1) / _Count; if (pageIndex < (allianceCount - 1) / _Count) { pageIndex = (allianceCount - 1) / _Count; } Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString())); } return(pageTable); }