public TournamentBDO CreateNewTournament(TournamentBDO tournamentToCreate)
 {
     try
     {
         using (var context = _contextFactory.Create())
         {
             var tournamentEntity = tournamentToCreate.MapToEntity();
             context.Tournaments.Add(tournamentEntity);
             context.SaveChanges();
             return tournamentEntity.MapToDomainObject();
         }
     }
     catch (Exception exception)
     {
         throw new ArgumentException("Tournament not created.", exception.InnerException);
     }
 }
Пример #2
0
        public TournamentBDO CreateNewTournament(TournamentVm tournamentToCreate)
        {
            var tournamentBDO = new TournamentBDO
            {
                Description = tournamentToCreate.Description,
                Type = tournamentToCreate.Type,
                Owner = tournamentToCreate.Owner
            };

            //TODO: refactor this hack.
            var updatedPlayerList = tournamentToCreate.PlayerLogins.ToList();
            updatedPlayerList.Add(tournamentBDO.Owner);

            var createdTournament = _tournamentRepository.CreateNewTournament(tournamentBDO);
            _tournamentRepository.AssignPlayersToTournament(createdTournament.TournamentId,
                updatedPlayerList);

            return createdTournament;
        }
 public TournamentBDO CreateNewTournament(TournamentBDO tournamentToCreate)
 {
     _tournaments.Add(tournamentToCreate);
     return tournamentToCreate;
 }