コード例 #1
0
        // GET: Matches/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var match = await _context.Matches
                        .Include(m => m.MatchDetail)
                        .ThenInclude(md => md.Team)
                        .FirstOrDefaultAsync(m => m.MatchId == id);

            if (match == null)
            {
                return(NotFound());
            }

            var view = new MatchDetailsViewModel()
            {
                MatchId   = match.MatchId,
                MatchDate = match.MatchDate,
                Location  = match.Location,
                HomeTeam  = match.MatchDetail.Where(md => md.IsHomeTeam).First().Team,
                HomeScore = match.MatchDetail.Where(md => md.IsHomeTeam).First().Score,
                AwayTeam  = match.MatchDetail.Where(md => !md.IsHomeTeam).First().Team,
                AwayScore = match.MatchDetail.Where(md => !md.IsHomeTeam).First().Score
            };

            return(View(view));
        }
コード例 #2
0
 public MatchDetailsPage(MatchSchedule matchSchedule)
 {
     InitializeComponent();
     BindingContext = model = new MatchDetailsViewModel()
     {
         Match = matchSchedule
     };
 }
コード例 #3
0
        // GET: Matches/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Match match = db.Matches
                          .Include(m => m.HomeTeam)
                          .Include(m => m.AwayTeam)
                          .Include(m => m.Votes)
                          .FirstOrDefault(m => m.Id == id);

            if (match == null)
            {
                return(HttpNotFound());
            }

            MatchDetailsViewModel viewModel = new MatchDetailsViewModel();

            viewModel.Match = match;

            viewModel.HomeTeamHistory = db.Matches
                                        .Include(m => m.HomeTeam)
                                        .Include(m => m.AwayTeam)
                                        .Where(m => (m.HomeTeam.Name == match.HomeTeam.Name || m.AwayTeam.Name == match.HomeTeam.Name) && m.IsResultUpdated && m.DateTime < match.DateTime)
                                        .OrderByDescending(m => m.DateTime)
                                        .Take(10)
                                        .ToList();

            viewModel.AwayTeamHistory = db.Matches
                                        .Include(m => m.HomeTeam)
                                        .Include(m => m.AwayTeam)
                                        .Where(m => (m.HomeTeam.Name == match.AwayTeam.Name || m.AwayTeam.Name == match.AwayTeam.Name) && m.IsResultUpdated && m.DateTime < match.DateTime)
                                        .OrderByDescending(m => m.DateTime)
                                        .Take(10)
                                        .ToList();

            viewModel.LeagueTeams = db.Teams
                                    .Where(t => t.LeagueId == match.LeagueId)
                                    .OrderByDescending(t => t.Points)
                                    .ThenByDescending(t => t.GoalsFor - t.GoalsAgainst)
                                    .ThenByDescending(t => t.GoalsFor)
                                    .ToList();

            viewModel.LeagueName = db.Leagues.Find(match.LeagueId).Name;

            return(View(viewModel));
        }
コード例 #4
0
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                throw new ApplicationException($"Passed ID parameter is absent.");
            }

            var match = await _matchService.FindAsync(id);

            if (match == null)
            {
                throw new ApplicationException($"Unable to find match with ID '{id}'.");
            }

            var model = new MatchDetailsViewModel(match);

            return(View(model));
        }
コード例 #5
0
        public IActionResult Index(int id)
        {
            var match = matchService.Get(id);

            var matchViewModel = new MatchDetailsViewModel
            {
                SeasonId         = match.Season.Id,
                ChampionshipName = match.Season.Championship.Name,
                PlayedOn         = match.PlayedOn,
                HomeTeamName     = match.HomeTeam.Name,
                HomeTeamGoals    = match.HomeTeamGoals,
                AwayTeamGoals    = match.AwayTeamGoals,
                AwayTeamName     = match.AwayTeam.Name,
                StadiumName      = match.Stadium.Name,
                Attendance       = match.Attendance,
                MainRefereeName  = match.Referee.Name
            };

            return(View(matchViewModel));
        }
コード例 #6
0
        public async Task <IActionResult> Details(string id)
        {
            try
            {
                var match = await _matchListService.GetMatchService(UserId, id);

                var matchState = await match.GetStateAsync();

                var matchDetailsViewModel = new MatchDetailsViewModel
                {
                    Id         = id,
                    MatchModel = matchState,
                    UserId     = UserId
                };

                return(View(matchDetailsViewModel));
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
        }
コード例 #7
0
        /**
         * Match details
         */
        public IActionResult Details(int id)
        {
            Match matchDetails = _matchRepository.Get(id);

            List <Player> hostSquad  = new List <Player>();
            List <Player> guestSquad = new List <Player>();

            foreach (MatchPlayer matchPlayer in matchDetails.MatchPlayers)
            {
                if (matchPlayer.Player.TeamId == matchDetails.HostTeamId)
                {
                    hostSquad.Add(matchPlayer.Player);
                }
                else if (matchPlayer.Player.TeamId == matchDetails.GuestTeamId)
                {
                    guestSquad.Add(matchPlayer.Player);
                }
            }

            MatchDetailsViewModel model = new MatchDetailsViewModel()
            {
                Id            = matchDetails.Id,
                HostTeamId    = matchDetails.HostTeamId,
                HostTeamName  = matchDetails.HostTeam.Name,
                GuestTeamId   = matchDetails.GuestTeamId,
                GuestTeamName = matchDetails.GuestTeam.Name,
                HostScore     = matchDetails.HostScore,
                GuestScore    = matchDetails.GuestScore,
                Place         = matchDetails.Place,
                Date          = matchDetails.Date,
                Status        = matchDetails.Status,
                HostSquad     = hostSquad,
                GuestSquad    = guestSquad
            };


            return(View(model));
        }