private async Task <BonusPrediction[]> GetBonusPredictionsFor(BonusPredictionType bonusPredictionType, long betGroupId)
 {
     return(await _dbContext.BonusPredictions
            .Where(q => q.BonusPredictionType == bonusPredictionType && q.UserBetGroup.BetGroupId == betGroupId)
            .Include(m => m.UserBetGroup.User)
            .Include(m => m.Team)
            .ToArrayAsync());
 }
        private MatchType GetMatchTypeBasedOfPredictionType(BonusPredictionType bonusPredictionType)
        {
            if (bonusPredictionType == BonusPredictionType.FirstTeamInWorldCup)
            {
                return(MatchType.Final);
            }
            if (bonusPredictionType == BonusPredictionType.SecondTeamInWorldCup)
            {
                return(MatchType.Final);
            }
            if (bonusPredictionType == BonusPredictionType.ThirdTeamInWorldCup)
            {
                return(MatchType.ThirdPlacePlayOff);
            }

            return(MatchType.Group);
        }
        internal int CalculateBonusScoreForTopNotch(long?teamId, Match match, BonusPredictionType bonusPredictionType)
        {
            if (match == null)
            {
                return(0);
            }

            if (!match.HomeTeamScore.MatchResult.HasValue)
            {
                return(0);
            }

            var winnderId = 0L;

            if (match.MatchWinner != null)
            {
                winnderId = match.MatchWinner.Id;
            }
            else if (match.PenaltyWinner != null)
            {
                winnderId = match.PenaltyWinner.Id;
            }

            if (teamId != winnderId)
            {
                return(0);
            }

            if (bonusPredictionType == BonusPredictionType.FirstTeamInWorldCup)
            {
                return(6);
            }
            if (bonusPredictionType == BonusPredictionType.SecondTeamInGroup)
            {
                return(5);
            }
            if (bonusPredictionType == BonusPredictionType.ThirdTeamInWorldCup)
            {
                return(4);
            }

            return(0);
        }