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)); }
public IActionResult Register(int id) { var loggedUserId = _userManager.FindByNameAsync(User.Identity.Name).Result.Id; RegisterTeamDto model = new RegisterTeamDto { OwnedTeams = _mapper.Map <List <TeamListDto> >(_teamService.GetOwnedTeamsByUserId(loggedUserId)), Tournament = _mapper.Map <TournamentListAllDto>(_tournamentService.GetTournamentWithAllTablesById(id)), AppUserId = loggedUserId }; return(View(model)); }