Example #1
0
        public int GetTotalScoreForUserUntilRound(User user, Round untilRound)
        {
            var totalscore = 0;

            foreach (var game in _games.Where(g => g.IsPlayed && g.Date <= untilRound.EndActive))
            {
                var gus = new GameUserScore
                {
                    Game            = game,
                    User            = user,
                    MatchPrediction = _matchPredictions.First(mp => mp.UserId == user.Id && mp.MatchId == game.Id)
                };
                totalscore += gus.ScoreThisGame;
            }
            foreach (var round in _rounds.Where(r => r.StartActive.HasValue && r.StartActive <= untilRound.StartActive))
            {
                var rus = new RoundUserScore
                {
                    Round           = round,
                    User            = user,
                    RoundPrediction = _roundPredictions.First(rp => rp.UserId == user.Id && rp.RoundId == round.Id),
                };
                totalscore += rus.ScoreThisRound;
            }
            return(totalscore);
        }
Example #2
0
        public int GetTotalScoreForUserUntilGame(User user, Game untilGame)
        {
            var totalscore = 0;

            //foreløpig for gruppespill
            foreach (var game in _games.Where(g => g.IsPlayed && g.Date <= untilGame.Date))
            {
                var gus = new GameUserScore
                {
                    Game            = game,
                    User            = user,
                    MatchPrediction = _matchPredictions.First(mp => mp.UserId == user.Id && mp.MatchId == game.Id)
                };
                totalscore += gus.ScoreThisGame;
            }
            //sluttspill
            foreach (var round in _rounds.Where(r => r.StartActive <= untilGame.Date))
            {
                var rp  = _roundPredictions.First(rpr => rpr.RoundId == round.Id && rpr.UserId == user.Id);
                var rus = new RoundUserScore
                {
                    Round           = round,
                    RoundPrediction = rp,
                    User            = user
                };
                if (untilGame.Date != null)
                {
                    totalscore += rus.ScoreThisRoundBeforeDateTime(untilGame.Date.Value.AddHours(3));
                }
            }
            return(totalscore);
        }