public SeasonTableModelView(Season season, IQueryable<Comment> Comments, Player CurrentPlayer) { SeasonEnd = season.SeasonEnd; SeasonStarts = season.SeasonStarts; //get active players Rows = season.GetActivePlayers().Select(p => new SeasonTablePlayerRow(p, season.GetPlayerPoints(p), season)) .OrderByDescending(x => x.TotalPoints).ToArray(); ColumnNames = season.Weeks.WeeksSoFar().Select(x => x.WeekStarts.ToString("dd MMM")).ToArray(); //comments CommentModel = new CommentingViewModel(8, season.Id, Comments, CurrentPlayer); }
public virtual int CurrentTotalPoints(Season season) { return season.GetPlayerPoints(this).Sum(); }
private static string BuildLeagueTable(Season season) { var WeeksSoFar = season.Weeks.WeeksSoFar(); StringBuilder sb = new StringBuilder(); sb.Append("<table style='font-size:12px;border-collapse:collapse' cellspacing='5' cellpadding='5'>"); sb.Append("<tr style='background:#FFFCD6'>"); sb.Append("<th colspan='2'>Week Start Date</th>"); foreach (var Week in WeeksSoFar) { sb.Append("<th style='text-align:right'>" + Week.WeekStarts.ordinalDateMonth() + "</th>"); } sb.Append("<th rowspan='2'>Total</th>"); sb.Append("</tr>"); sb.Append("<tr style='background:#FFFCD6'>"); sb.Append("<th colspan='2'>Players / Week</th>"); for (var j = 1; j <= WeeksSoFar.Count(); j++) { sb.Append("<th style='text-align:right'>" + string.Format("Week #{0}", j) + "</th>"); } sb.Append("</tr>"); int i = 1; // for each players foreach (var p in season.GetLivePlayers().OrderByDescending(x=>x.CurrentTotalPoints(season))){ var GetPlayersPoints = season.GetPlayerPoints(p); sb.Append(string.Format("<tr{0}>", i % 2 == 0 ? "" : " style='background:#eeeeee'")); sb.Append("<td>" + string.Format("{0}#", i) + "</td>"); sb.Append("<td>" + p.Name + "</a></td>"); //for each week foreach(var pts in GetPlayersPoints){ sb.Append("<td style='text-align:right'>" + pts + "</td>"); } sb.Append("<td style='text-align:right'>" + GetPlayersPoints.Sum() + "</td>"); sb.Append("</tr>"); i += 1; } sb.Append("</table>"); return sb.ToString(); }
public SeasonTableModelCaching(Season season) { SeasonEnd = season.SeasonEnd; SeasonStarts = season.SeasonStarts; SeasonId = season.Id; //get active players Rows = season.GetActivePlayers().Select(p => new SeasonTablePlayerRow(p, season.GetPlayerPoints(p), season)) .OrderByDescending(x => x.TotalPoints).ToArray(); ColumnNames = season.Weeks.WeeksSoFar().Select(x => x.WeekStarts.ToString("dd MMM")).ToArray(); }