Example #1
0
        public IActionResult PlayerOfTheYear()
        {
            var result = _statisticsService
                         .TotalElo(GameTypes.TableTennis, new DateTime(2020, 1, 1), new DateTime(2020, 12, 31))
                         .OrderByDescending(pair => pair.Value.First().Value).ToList();

            var maxEloTotalScore = result.Max(pair => pair.Value["total elo"]).Round();
            var speedNumberOne   = result.First().Value["elo/h"];

            var index     = 1;
            var viewModel = new ViewItems
            {
                Headers = new List <string>()
                {
                    "Total Elo", "Diff", "Behind in hours", "Elo/day", "Elo/hour"
                },
                Values = result.Select(pair =>
                {
                    var viewItem = new ViewItem {
                        Index = (index++).ToString(), Name = pair.Key.DisplayName,
                    };
                    viewItem.Scores.Add(pair.Value["total elo"].Round().ToString());
                    var diffScore = (pair.Value["total elo"].Round() - maxEloTotalScore);
                    viewItem.Scores.Add(diffScore.ToString());

                    var thisSpeed = pair.Value["elo/h"].Round();
                    if (thisSpeed > speedNumberOne)
                    {
                        var timeNeeded = -1 * diffScore / (thisSpeed - speedNumberOne);
                        viewItem.Scores.Add(timeNeeded.Round().ToString());
                    }
                    else
                    {
                        viewItem.Scores.Add("");
                    }

                    //viewItem.Scores.Add(pair.Value["avg elo"].Round().ToString());
                    viewItem.Scores.Add(pair.Value["current elo"].Round().ToString());

                    viewItem.Scores.Add(pair.Value["elo/h"].Round().ToString());
                    return(viewItem);
                })
            };

            ViewBag.Title = "Player of the Year";
            return(View("MultiValues", viewModel));
        }
Example #2
0
        public IActionResult AverageElo(int year)
        {
            var result = _statisticsService
                         .TotalElo(GameTypes.TableTennis, new DateTime(year, 1, 1), new DateTime(year, 12, 31))
                         .OrderByDescending(pair => pair.Value["prognose elo"])
                         .ToList();

            var index     = 1;
            var viewModel = new ViewItems
            {
                Headers = new List <string>()
                {
                    "Avg 31/12", "Avg Now", "Cur Elo", "Elo Needed"
                },
                Values = result.Select(pair =>
                {
                    var viewItem = new ViewItem
                    {
                        Index = (index++).ToString(),
                        Name  = pair.Key.DisplayName,
                    };

                    viewItem.Scores.Add(pair.Value["prognose elo"].Round().ToString());

                    viewItem.Scores.Add(pair.Value["avg elo"].Round().ToString());
                    viewItem.Scores.Add(pair.Value["current elo"].Round().ToString());
                    viewItem.Scores.Add(pair.Value["needed"].Round().ToString());

                    return(viewItem);
                })
            };



            ViewBag.Title = "Average Elo Score " + year;
            //return View("PlayerOfTheYear", viewModel);
            return(View("MultiValues", viewModel));
        }