/// <summary>
        /// Berechnet aus den Ergebnissen den aktuellen WM-Stand für die Teams
        /// </summary>
        /// <returns>DTO für die Teamergebnisse</returns>
        public static IEnumerable <TotalResultDto <Team> > GetTeamWmTable()
        {
            var team = ImportController.LoadResultsFromXmlIntoCollections();

            return(team
                   .GroupBy(t => t.Team)
                   .Select(s => new TotalResultDto <Team>()
            {
                Competitor = s.Key,
                Points = s.Sum(p => p.Points)
            }).OrderByDescending(o => o.Points)
                   .ThenBy(c => c.Competitor));
        }
        /// <summary>
        /// Berechnet aus den Ergebnissen den aktuellen WM-Stand für die Fahrer
        /// </summary>
        /// <returns>DTO für die Fahrerergebnisse</returns>
        public static IEnumerable <TotalResultDto <Driver> > GetDriverWmTable()
        {
            var drivers = ImportController.LoadResultsFromXmlIntoCollections();

            return(drivers
                   .GroupBy(s => s.Driver)
                   .Select(t => new TotalResultDto <Driver>()
            {
                Competitor = t.Key,
                Points = t.Sum(p => p.Points)
            })
                   .OrderByDescending(d => d.Points)
                   .ThenBy(l => l.Competitor.Lastname));
        }
Пример #3
0
        /// <summary>
        /// Berechnet aus den Ergebnissen den aktuellen WM-Stand für die Teams
        /// </summary>
        /// <returns>DTO für die Teamergebnisse</returns>
        public static IEnumerable <TotalResultDto <Team> > GetTeamWmTable()
        {
            List <Result> results = ImportController.LoadResultsFromXmlIntoCollections().ToList();
            var           result  = results
                                    .GroupBy(gb => gb.Team)
                                    .Select(team => new TotalResultDto <Team>
            {
                Competitor = team.First().Team,
                Points     = team.Sum(s => s.Points)
            }
                                            ).ToList();

            result.Sort();
            for (int i = 0; i < result.Count; i++)
            {
                result[i].Position = (i + 1);
            }
            return(result);
        }