Пример #1
0
        //Tournaments/Details/Id
        public ActionResult Details(string id)
        {
            //var userId = User.Identity.GetUserId();
            var userId = "3f310a65-509d-43a2-8714-c7626992c3d8";

            //var tournamentInDb = _context.Tournaments.Single(t => t.Id == Id && t.CreatorId == userId);
            var tournamentInDb = _unitOfWork.Tournaments.GetTournamentWithAll(id);

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

            if (tournamentInDb.CreatorId != userId)
            {
                return(new HttpUnauthorizedResult());
            }

            //var playersInDb = _context.Players.Where(p => p.TournamentId == tournamentInDb.Id).Include(c => c.Team).ToList();

            var viewModel = new TournamentDetailsViewModel
            {
                Title            = "Tournament Details",
                Id               = tournamentInDb.Id,
                Name             = tournamentInDb.Name,
                NumberOfPlayers  = tournamentInDb.NumberOfPlayers,
                TournamentTypeId = tournamentInDb.TournamentTypeId,
                TournamentTypes  = _unitOfWork.TournamentTypes.GetAll(),
                Matches          = _unitOfWork.Matches.Find(m => m.TournamentId == id)
            };

            return(View("Details", viewModel));
        }
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                throw new ApplicationException($"Passed ID parameter is absent.");
            }

            var tournament = await _tournamentService.FindAsync(id);

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

            var model = new TournamentDetailsViewModel(tournament);

            return(View(model));
        }
        public ActionResult Details(int id)
        {
            var tournament = _unitOfWork.Tournaments.GetTournament(id);



            var viewModel = new TournamentDetailsViewModel
            {
                Tournament = tournament
            };

            if (User.Identity.IsAuthenticated)
            {
                var userId = User.Identity.GetUserId();
                viewModel.IsParticipating = _unitOfWork.Participations.GetParticipation(tournament.Id, userId) != null;
            }
            return(View("Details", viewModel));
        }
Пример #4
0
        // GET: Tournaments/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TournamentDetailsViewModel tournamentDetailsViewModel = new TournamentDetailsViewModel();

            Tournament tournament = db.Tournaments.Find(id);

            if (tournament == null)
            {
                return(HttpNotFound());
            }
            tournamentDetailsViewModel.id          = tournament.Id;
            tournamentDetailsViewModel.Leaderboard = this.GetLeaderboard(id);
            tournamentDetailsViewModel.Name        = tournament.Name;

            return(View(tournamentDetailsViewModel));
        }
        public ActionResult Details(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(this.View("Error"));
            }

            var tournament = this.tournamentService.GetTournamentById(id);

            var viewModel = new TournamentDetailsViewModel()
            {
                Name                  = tournament.Name,
                Place                 = tournament.Place,
                StartDate             = tournament.StartDate,
                EndDate               = tournament.EndDate,
                Country               = tournament.Country,
                DivisionsInTournament = tournament.DivisionsInTournament.ToList()
            };

            return(this.View(viewModel));
        }
Пример #6
0
        // GET: Tournament/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tournament tournament = db.Tournaments.Find(id);

            if (tournament == null)
            {
                return(HttpNotFound());
            }
            var games      = db.Games.Where(g => g.TournamentId == id).ToList();
            var playerList = games.Select(p => p.HomePlayerId).Union(games.Select(p => p.AwayPlayerId).Distinct().ToList());

            var players = db.Players.Where(p => playerList.Contains(p.Id)).ToList();

            var standings = tournamentHelper.GenerateStandings(players, games);

            var tournamentAdministrator = (User.Identity.IsAuthenticated && User.Identity.GetUserId() == tournament.UserId) || Request.Cookies["TournamentAdministrator"] != null && Convert.ToInt32(Request.Cookies["TournamentAdministrator"].Value) == tournament.Id;
            var scheduleVm = new ScheduleViewModel()
            {
                Games   = games,
                Players = players,
                TournamentAdministrator = tournamentAdministrator
            };

            var vm = new TournamentDetailsViewModel()
            {
                Schedule   = scheduleVm,
                Tournament = tournament,
                Standings  = standings
            };

            return(View(vm));
        }