public int CreateTournament(TournamentInstance tournament) { var entity = Mapper.Map <Entities.Tournament>(tournament); _tournamentRepository.Add(entity); _tournamentRepository.SaveChanges(); return(entity.TournamentId); }
public void AddTournament_ValidTournament_SavedTournament() { var tournament = new TournamentDto { Date = new DateTime(2015, 2, 1), MaxPlayerPerTeam = 6, TotalTeam = 4 }; tournament.Id = tournamentGuid.ToString(); tournamentRepository.Add(tournament); }
public IActionResult OnPostCreate() { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; ApplicationUserRepository userRepository = new ApplicationUserRepository(context); var user = userRepository.Get(userId); var tournament = new Tournament { Status = TournamentStatus.Draft, CreatedAt = DateTime.Now, DueDate = DateTime.Now.AddMonths(1), Owner = user, Name = "Draft " + DateTime.Now.ToShortDateString() }; repository.Add(tournament); int tournamentId = tournament.TournamentId; return(RedirectToPage("Edit", new { id = tournamentId })); }