コード例 #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));
        }
コード例 #2
0
        public async Task <RequestResponseModel <LeagueViewModel> > GetLeagueByIdAsync(int leagueId, bool includeTeams, bool includeGames)
        {
            var league = (LeagueViewModel)await _leagueRepository.GetLeagueByIdAsync(leagueId, includeTeams, includeGames);

            if (league == null)
            {
                return(new RequestResponseModel <LeagueViewModel>(StatusCodes.Status404NotFound,
                                                                  new List <ErrorViewModel>
                {
                    ErrorViewModel.Factory.NewErrorFromMessage(_localizer["LeagueNotFoundErrorMessage"]
                                                               .Value)
                },
                                                                  null));
            }

            return(new RequestResponseModel <LeagueViewModel>(StatusCodes.Status200OK,
                                                              Enumerable.Empty <ErrorViewModel>(),
                                                              league));
        }
コード例 #3
0
ファイル: LeagueValidator.cs プロジェクト: GokitaU/Betto
 public async Task <bool> CheckDoesTheLeagueExistAsync(int leagueId) =>
 await _leagueRepository.GetLeagueByIdAsync(leagueId, false, false) != null;