public ITournament deleteTournament(int id)
        {
            var tournament = getTournament(id);

            foreach (var round in tournament.Rounds)
            {
                foreach (var matchup in round.Matchups)
                {
                    foreach (var matchupEntry in matchup.MatchupEntries)
                    {
                        MatchupEntriesTable.Delete(matchupEntry, dbConn);
                    }
                    MatchupsTable.Delete(matchup, dbConn);
                }
                RoundsTable.Delete(round, dbConn);
            }

            foreach (var tournamentEntry in tournament.TournamentEntries)
            {
                TournamentEntryTable.Delete(tournamentEntry, dbConn);
            }

            foreach (var tournamentPrize in tournament.TournamentPrizes)
            {
                TournamentPrizesTable.Delete(tournamentPrize, dbConn);
            }

            TournamentTable.Delete(tournament, dbConn);
            return(tournament);
        }
        public ITournament getTournament(int id)
        {
            var tournament           = TournamentTable.Get(id, dbConn);
            var allRounds            = RoundsTable.GetAll(dbConn);
            var allMatchups          = MatchupsTable.GetAll(dbConn);
            var allMatchupEntries    = MatchupEntriesTable.GetAll(dbConn);
            var allTournamentEntries = TournamentEntryTable.GetAll(dbConn);
            var allTeams             = TeamsTable.GetAll(dbConn);
            var allTeamMembers       = TeamMembersTable.GetAll(dbConn);
            var allPersons           = PersonsTable.GetAll(dbConn);
            var allTournamentPrizes  = TournamentPrizesTable.GetAll(dbConn);

            tournament.TournamentEntries = allTournamentEntries.Where(x => x.TournamentId == tournament.TournamentId).ToList();
            tournament.TournamentPrizes  = allTournamentPrizes.Where(x => x.TournamentId == tournament.TournamentId).ToList();

            foreach (var entry in tournament.TournamentEntries)
            {
                var entryMembers = allTeamMembers.Where(x => x.TeamId == entry.TeamId).ToList();
                foreach (var member in entryMembers)
                {
                    entry.Members.Add(allPersons.Find(x => x.PersonId == member.PersonId));
                }
                var theTeam = allTeams.Where(x => x.TeamId == entry.TeamId).First();
                tournament.Teams.Add(theTeam);
            }
            tournament.Rounds = allRounds.Where(x => x.TournamentId == tournament.TournamentId).ToList();
            foreach (var round in tournament.Rounds)
            {
                round.Matchups = allMatchups.Where(x => x.RoundId == round.RoundId).ToList();
                foreach (var matchup in round.Matchups)
                {
                    matchup.MatchupEntries = allMatchupEntries.Where(x => x.MatchupId == matchup.MatchupId).ToList();
                    foreach (var team in matchup.MatchupEntries)
                    {
                        team.TheTeam = tournament.TournamentEntries.Where(x => x.TournamentEntryId == team.TournamentEntryId).First();
                    }
                }
            }

            return(tournament);
        }
        public ITournament createTournament(ITournament entry)
        {
            ITournament tournament = TournamentTable.Create(entry, dbConn);

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

            entry.TournamentEntries.ForEach(x => x.TournamentId = tournament.TournamentId);
            entry.TournamentEntries.ForEach(x => TournamentEntryTable.Create(x, dbConn));
            entry.TournamentPrizes.ForEach(x => x.TournamentId = tournament.TournamentId);
            entry.TournamentPrizes.ForEach(x => TournamentPrizesTable.Create(x, dbConn));

            entry.Rounds.ForEach(x => x.TournamentId = tournament.TournamentId);

            foreach (var round in entry.Rounds)
            {
                round.RoundId = RoundsTable.Create(round, dbConn).RoundId;
                CreateRoundLinks(round, entry.TournamentEntries);
            }

            return(tournament);
        }