Example #1
0
        public IActionResult OnGet()
        {
            Predictions = _predictionData.GetAll();
            var EntityGames = Predictions.Select(p => p.Game).Distinct().OrderBy(g => g.Order);

            Games = new List <GameEditModel>();
            foreach (var game in EntityGames)
            {
                if (Games.All(g => g.Id != game.Id))
                {
                    Games.Add(_gameConverter.ToEditModel(game));
                }
            }
            Users       = _userData.GetAll();
            TotalScores = new Dictionary <int, int>();
            foreach (var user in Users)
            {
                var total = 0;
                foreach (var p in Predictions.Where(p => p.User.Id == user.Id))
                {
                    total += _scoreCalculator.Calculate(p.Game.HalftimeScore, p.Game.FulltimeScore, p.HalftimeScore,
                                                        p.FulltimeScore);
                }
                TotalScores.Add(user.Id, total);
            }
            return(Page());
        }
Example #2
0
        public IActionResult OnGet()
        {
            var predictions = _predictiondata.GetAll();

            Predictions = new List <PredictionEditModel>();

            foreach (var p in predictions)
            {
                var b = _converter.ToPredictionEditModel(p);
                Predictions.Add(b);
            }

            return(Page());
        }