public static string GetCourseHeader( List <DisplayTable> listDisplayTable, DisplayTable displayTable, DisplayCourse displayCourse) { if (displayTable.ListDisplayCourses.First() != displayCourse) { return(displayCourse.CourseId); } if (displayTable.Id == 1) { return(displayCourse.CourseId); } var previousCourse = listDisplayTable.Single(c => c.Id == displayTable.Id - 1).ListDisplayCourses.Last().ListDisplayRows.Last().Course; var compare = (displayCourse.CourseId == previousCourse) ? true : false; return((compare == true) ? previousCourse + "..." : displayCourse.CourseId); }
private TableRowCount BuildDisplayRow(List <CompetitorResultSummary> competitorResultSummaries, TableRowCount tableRowCount) { var data = competitorResultSummaries.GroupBy(c => c.CourseId) .Select(group => new { course = group.Key, Items = group.ToList() }) .ToList(); int mensClassCount; int womensClassCount; var isContunation = false; if (tableRowCount.LastCourse == data[0].course) { isContunation = true; } courseCount = 1; mensClassCount = 1; womensClassCount = 1; for (int i = 1; i <= data.Count; i++) { if (isContunation) { courseCount = tableRowCount.LastCourseCount; mensClassCount = tableRowCount.LastMensClassCount; womensClassCount = tableRowCount.LastWomensClassCount; isContunation = false; } else { courseCount = 0; mensClassCount = 0; womensClassCount = 0; } for (int j = 1; j <= data[i - 1].Items.Count; j++) { var leaderTime = data[i - 1].Items[0].ElapsedTime; var item = data[i - 1].Items[j - 1]; courseCount += 1; if (Shared.GetGenderFromClass(item.ClassId) == "men") { mensClassCount += 1; } else { womensClassCount += 1; } var genderCount = (Shared.GetGenderFromClass(item.ClassId) == "men") ? (mensClassCount).ToString() : (womensClassCount).ToString(); var displayRow = new DisplayRow { Id = courseCount, Course = data[i - 1].course, Class = item.ClassId, ClassCount = genderCount, Status = item.Status, Name = _competitorService.Get(item.SI).Name, SI = item.SI.ToString(), ElapsedTime = (TimeSpan)item.ElapsedTime, TimeDifference = Shared.GetTimeDiffFromLeader(leaderTime, item.ElapsedTime, item.Status, j), Penalty = item.Penalty, NetScore = (item.Score - item.Penalty) }; listDisplayRow.Add(displayRow); } var displayCourse = new DisplayCourse { Id = i, CourseId = data[i - 1].course, LeaderTime = (i == 1) ? data[i - 1].Items[0].ElapsedTime : null, ListDisplayRows = listDisplayRow }; listDisplayCourses.Add(displayCourse); tableRowCount.LastCourseCount = listDisplayRow.Select(c => c.Id).Max(); tableRowCount.LastMensClassCount = mensClassCount; tableRowCount.LastWomensClassCount = womensClassCount; tableRowCount.LastCourse = listDisplayRow.Last().Course; listDisplayRow = new List <DisplayRow>(); } //Build the table AddToDisplayTable(listDisplayCourses, tableRowCount.Id); listDisplayRow = new List <DisplayRow>(); listDisplayCourses = new List <DisplayCourse>(); return(tableRowCount); }