Beispiel #1
0
        public ActionResult GetMatchBetsResults(Guid matchId)
        {
            var match = this.matchesService.GetMatch(matchId);

            if (match == null)
            {
                throw new Exception("El partido especificado no existe!");
            }

            var result = this.matchResultsService.GetResultByMatch(matchId);

            if (match == null)
            {
                throw new Exception("No esta cargado el resultado para el partido especificado!");
            }

            var bets  = this.matchBetsService.GetBetsByMatch(matchId).ToList();
            var users = this.usersService.Get().ToList();

            var countries = this.countriesService.GetCountries().ToList();
            var homeTeam  = countries.FirstOrDefault(x => match.HomeTeam.Equals(x.Id));
            var awayTeam  = countries.FirstOrDefault(x => match.AwayTeam.Equals(x.Id));

            var model = new BetResultsListViewModel
            {
                BetResultsList = bets.Select(x => new BetResultViewModel {
                    Bet = x, BetResult = GetBetResult(x, result), User = users.FirstOrDefault(u => u.Id.Equals(x.UserId))
                }).OrderByDescending(x => x.BetResult.Points),
                Match = new MatchViewModel
                {
                    Id                  = match.Id,
                    HomeTeamId          = match.HomeTeam,
                    HomeTeam            = homeTeam.Name,
                    HomeTeamCode        = homeTeam.Code,
                    HomeTeamGoals       = result.HomeGoals,
                    HomeTeamPenalties   = result.HomePenalties,
                    AwayTeamId          = match.AwayTeam,
                    AwayTeam            = awayTeam.Name,
                    AwayTeamCode        = awayTeam.Code,
                    AwayTeamGoals       = result.AwayGoals,
                    AwayTeamPenalties   = result.AwayPenalties,
                    PlayedOn            = match.PlayedOn.Value,
                    Stage               = match.Stage,
                    Completed           = match.PlayedOn <= DateTime.UtcNow,
                    PenaltiesDefinition = match.Stage.SupportPenalties() && result.HomeGoals == result.AwayGoals
                }
            };

            return(View(model));
        }
Beispiel #2
0
        public ActionResult BetResults(Guid id)
        {
            var match = this.matchesService.GetMatch(id);

            if (match == null)
            {
                return(RedirectToAction("AllMatches"));
            }

            var result     = this.matchResultsService.GetResultByMatch(id);
            var bets       = this.matchBetsService.GetBetsByMatch(id).ToList();
            var betResults = this.betResultsService.GetBetResultsByMatch(id).ToList();
            var users      = this.usersService.Get().ToList();

            var countries = this.countriesService.GetCountries().ToList();
            var homeTeam  = countries.FirstOrDefault(x => match.HomeTeam.Equals(x.Id));
            var awayTeam  = countries.FirstOrDefault(x => match.AwayTeam.Equals(x.Id));

            var model = new BetResultsListViewModel
            {
                BetResultsList = bets.Select(x => new BetResultViewModel {
                    Bet = x, BetResult = betResults.FirstOrDefault(r => r.Id.Equals(x.Id)), User = users.FirstOrDefault(u => u.Id.Equals(x.UserId))
                }).OrderByDescending(x => x.BetResult?.Points),
                Match = new MatchViewModel
                {
                    Id                  = match.Id,
                    HomeTeamId          = match.HomeTeam,
                    HomeTeam            = homeTeam.Name,
                    HomeTeamCode        = homeTeam.Code,
                    HomeTeamGoals       = result?.HomeGoals,
                    HomeTeamPenalties   = result?.HomePenalties,
                    AwayTeamId          = match.AwayTeam,
                    AwayTeam            = awayTeam.Name,
                    AwayTeamCode        = awayTeam.Code,
                    AwayTeamGoals       = result?.AwayGoals,
                    AwayTeamPenalties   = result?.AwayPenalties,
                    PlayedOn            = match.PlayedOn.Value,
                    Stage               = match.Stage,
                    Completed           = match.PlayedOn <= DateTime.UtcNow,
                    PenaltiesDefinition = match.Stage.SupportPenalties() && result != null && result.HomeGoals == result.AwayGoals
                }
            };

            return(View(model));
        }