Ejemplo n.º 1
0
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var tournament = tournamentService.GetById((int)id);

            if (tournament == null)
            {
                return(HttpNotFound());
            }
            var team = new Team()
            {
                TournamentId = (int)id, Coach = User.Identity.Name
            };
            TeamViewModel _teamViewModel = new TeamViewModel()
            {
                Team        = team,
                CountryList = GetCountryList(),
                RankingList = GetRankingList(tournament)
            };

            return(View(_teamViewModel));
        }
 public ActionResult <Tournament> GetById(int tournamentId)
 {
     if (tournamentService.GetById(tournamentId) == null)
     {
         return(NotFound());
     }
     return(Ok(tournamentService.GetById(tournamentId)));
 }
Ejemplo n.º 3
0
        //[Authorize(Roles = PlayerRolesConst.MainPlayer)]
        public IActionResult Get(Guid id)
        {
            var result = _tournamentService.GetById(id);

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

            return(Ok(result));
        }
Ejemplo n.º 4
0
        // GET: Tournament/Details/5
        public ActionResult Details(int id)
        {
            var tournamentBL = _tournamentService.GetById(id);

            var tournament = _mapper.Map <TournamentDetailsModel>(tournamentBL);

            var hosts = new List <string>();

            if (tournamentBL.HostsId != null)
            {
                var hostsId = tournamentBL.HostsId.Split(';');

                var userManager = Request.GetOwinContext().GetUserManager <ApplicationUserManager>();
                foreach (var hostId in hostsId)
                {
                    var host = userManager.Users.FirstOrDefault(u => u.Id == hostId);
                    if (host != null)
                    {
                        hosts.Add(host.UserName);
                    }
                }
            }
            tournament.TournamentHosts = hosts;

            return(View(tournament));
        }
        public IActionResult Register(RegisterTeamDto model)
        {
            var loggedUserId = _userManager.FindByNameAsync(User.Identity.Name).Result.Id;
            var tournament   = _tournamentService.GetById(model.TournamentId);

            if (loggedUserId != model.AppUserId)
            {
                return(Unauthorized());
            }

            if (ModelState.IsValid)
            {
                _tournamentTeamsService.Add(new TournamentTeamsEntity
                {
                    TeamId       = model.TeamId,
                    TournamentId = model.TournamentId,
                    IsConfirmed  = tournament.StartDate.AddMinutes(-30) <= DateTime.Now ? true : false
                });

                return(RedirectToAction("Index", "Tournament", new { area = "", id = model.TournamentId }));
            }

            model.OwnedTeams = _mapper.Map <List <TeamListDto> >(_teamService.GetOwnedTeamsByUserId(_userManager.FindByNameAsync(User.Identity.Name).Result.Id));

            model.Tournament = _mapper.Map <TournamentListAllDto>(_tournamentService.GetTournamentWithAllTablesById(model.TournamentId));

            return(View(model));
        }
        private bool IsUpcoming(int tournamentId)
        {
            var tournament = _tournamentService.GetById(tournamentId);

            if (tournament == null || tournament.IsStarted || tournament.IsFinished)
            {
                return(false);
            }
            return(true);
        }
 public void Initialize(int?id)
 {
     if (id != null)
     {
         tournament = tournamentService.GetById((int)id);
     }
     else
     {
         tournament = null;
     }
 }
Ejemplo n.º 8
0
        // GET: Evenement/Details/5
        public ActionResult Details(int id)
        {
            tournament       item = tournamentService.GetById(id);
            TournamentModels t    = new TournamentModels
            {
                id_tournament          = item.id_tournament,
                description            = item.description,
                adresse                = item.adresse,
                name                   = item.name,
                image_link             = item.image_link,
                nbrPlaces              = item.nbrPlaces,
                broadcast_link         = item.broadcast_link,
                latitude               = item.latitude,
                longitude              = item.longitude,
                evenement              = item.evenement,
                evenement_id_Evenement = item.evenement_id_Evenement,
                url = item.url
            };

            return(View(t));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> TakePartInTournament(Guid playerId, Guid tournamentId)
        {
            var player     = _playerService.GetAllTournamentsOfPlayer(playerId);
            var tournament = _tournamentService.GetById(tournamentId);

            if (player == null || tournament == null)
            {
                return(NotFound("Player or tournament is not found"));
            }

            if (player.tournaments.Any(t => t.Id == tournamentId))
            {
                return(BadRequest());
            }

            //player.tournaments.Add(tournament);
            //tournament.players.Add(player);

            await _playerService.TakePartInTournament(player.Id, tournament.Id);

            return(Ok());
        }
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var tournament = tournamentService.GetById((int)id);

            if (tournament == null)
            {
                return(HttpNotFound());
            }
            RefereeViewModel refereeViewModel = new RefereeViewModel
            {
                Referee = new Referee()
                {
                    TournamentId = (int)id
                },
                PositionList = GetPositionList(tournament)
            };

            return(View(refereeViewModel));
        }
Ejemplo n.º 11
0
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var tournament = tournamentService.GetById((int)id);

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

            Category category = new Category()
            {
                TournamentId = (int)id
            };

            return(View(category));
        }
 IList <SelectListItem> GetCategoryList(int TournamentId)
 {
     return(tournamentService.GetById(TournamentId).Categories.ToSelectList(c => c.Id, s => String.Format("{0} [{1}] [{2}]", s.Gender.GetDisplayName(), s.Age, s.Weight)));
 }
Ejemplo n.º 13
0
        public PartialViewResult GetTeams(int id, int?page = 1, string active = "")
        {
            var        tournament     = tournamentService.GetById(id);
            HttpCookie pageSizeCookie = Request.Cookies["_pageSize"];
            int        pageSize       = Convert.ToInt16(pageSizeCookie.Value);

            var tab = new TableViewModel <Team>()
            {
                TableData           = tournament.Teams.OrderBy(x => x.Name).ToPagedList((int)page, pageSize),
                Active              = active,
                Controller          = "Tournaments",
                ChildController     = "Teams",
                TournamentOrganizer = tournament.Organizer,
                TournamentStatus    = tournament.Status
            };

            return(PartialView("_Teams", tab));
        }
 public async Task <Tournament> GetById(int id)
 {
     return(await _tournamentService.GetById(id));
 }