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

            decimal Wins = await leagueRepository.GetLeagueWins(LeagueId, TipTypeId);

            decimal Odds = await leagueRepository.GetLeagueAverageOdds(LeagueId, TipTypeId);

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

            LeagueViewModel lVM = new LeagueViewModel {
                LeagueTotalPlayed = TotalPlayed,
                LeagueWins        = Wins,
                LeaguePercentage  = Percentage,
                LeagueAverageOdds = Odds,
                LeagueRoi         = Roi,
                League            = await leagueRepository.GetLeagueByIdAsync(LeagueId),
                Predictions       = await leagueRepository.GetPredictionsByLeagueAndTipType(LeagueId, TipTypeId),
                TipStats          = await repository.GetTipStatsByLeague(TipTypeId, LeagueId),
                ControllerName    = "Statistics",
                TipTypeId         = TipTypeId
            };

            ViewData["TipTypeId"] = TipTypeId;
            return(View("League", lVM));
        }