コード例 #1
0
        public async Task <IActionResult> ShowTipsByLeagueAndTip(int TipTypeId, int TipId, int LeagueId)
        {
            decimal TotalPlayed = await leagueRepository.GetLeagueTotalPlayedByTip(LeagueId, TipId);

            decimal Wins = await leagueRepository.GetLeagueWinsByTip(LeagueId, TipId);

            decimal Odds = await leagueRepository.GetLeagueAverageOddsByTip(LeagueId, TipId);

            decimal Percentage = PercentageCalculator.CalculatePercentage(TotalPlayed, Wins);
            decimal Roi        = PercentageCalculator.CalculateRoi(TotalPlayed, Wins, Odds);


            LeagueTipDetailedViewModel VM = new LeagueTipDetailedViewModel
            {
                Tip               = await tipRepository.GetTipByTipId(TipId),
                League            = await leagueRepository.GetLeagueByIdAsync(LeagueId),
                LeagueTotalPlayed = TotalPlayed,
                LeagueWins        = Wins,
                LeagueAverageOdds = Odds,
                LeaguePercentage  = Percentage,
                LeagueRoi         = Roi,
                Predictions       = await leagueRepository.GetPredictionsByLeagueAndTip(LeagueId, TipId),
                ControllerName    = "Statistics",
                TipTypeId         = TipTypeId
            };

            ViewData["TipTypeId"] = TipTypeId;
            return(View("LeagueTipDetailed", VM));
        }
コード例 #2
0
        public async Task <ConcurrentDictionary <Tip, decimal[]> > GetTipStatsByTipAndLeague(int TipId, int LeagueId)
        {
            ConcurrentDictionary <Tip, decimal[]> TipStats = new ConcurrentDictionary <Tip, decimal[]>();

            Tip t = await tipRepository.GetTipByTipId(TipId);

            decimal Odds = await tipRepository.GetTipAverageOddsByLeague(TipId, LeagueId);

            decimal TotalPlayed = await tipRepository.GetTipTotalPlayedByLeague(TipId, LeagueId);

            decimal Wins = await tipRepository.GetTipWinsByLeague(TipId, LeagueId);

            TipStats.TryAdd(t, new decimal[] { Odds, TotalPlayed, Wins });
            return(TipStats);
        }