public TournamentManagerErrorCodes CreateTournament(TournamentDTO tournamentDTO) { if (tournamentDTO.BuyIn > 0 && (tournamentDTO.BuyIn * tournamentDTO.Size) >= tournamentDTO.Prize) { return(TournamentManagerErrorCodes.BuyInMoreOrEqualToPrize); } if (tournamentDTO.OrganisationID == "null" && tournamentDTO.UserID == "null") { return(TournamentManagerErrorCodes.NoHost); } tournamentDTO.ID = idGenerator.GenerateID(12); if (tournamentDTO.OrganisationID == "null") { tournamentDTO.OrganisationID = null; int extraCost = tournamentDTO.Prize - (tournamentDTO.BuyIn * tournamentDTO.Size); if (userDB.GetCurrency(tournamentDTO.UserID) < extraCost) { return(TournamentManagerErrorCodes.NotEnoughMoney); } } else { tournamentDTO.UserID = null; } tournamentDB.CreateTournament(tournamentDTO); return(TournamentManagerErrorCodes.NoError); }