Beispiel #1
0
        /// <summary>
        /// Get a list of the players for a specific Competition.
        /// </summary>
        /// <param name="competition"></param>
        /// <returns></returns>
        public static List <GamePlayerModel> GetPlayerRoster(CompetitionModel competition)
        {
            List <GamePlayerModel> returnList = null;

            if (competition.TeamsAreFixed)
            {
                // If teams are fixed, then look for a regular team first.
                returnList = CompetitionDataAccess.GetRegularTeams(competition.CompetitionID);
            }

            // If a regular team is not found, then get all the players.
            if ((competition.TeamsAreRandomised) || (returnList == null))
            {
                List <PlayerModel> players = CompetitionDataAccess.GetRegisteredPlayers(competition.CompetitionID);
                returnList = new List <GamePlayerModel>(players.Count);
                foreach (PlayerModel p in players)
                {
                    GamePlayerModel tfm = new GamePlayerModel
                    {
                        CompetitionID = competition.CompetitionID,
                        PlayerID      = p.PlayerID,
                        PlayerName    = p.PlayerName
                    };
                    returnList.Add(tfm);
                }
            }

            return(returnList);
        }
Beispiel #2
0
        /// <summary>
        /// Create a new Competition.
        /// Before insertion, checks to see if it exists.
        /// </summary>
        /// <param name="competition"></param>
        /// <returns>Returns the CompetitionModel (with CompetitionID populated) or null if not created.</returns>
        public static CompetitionModel GetOrCreateCompetition(CompetitionModel competition)
        {
            CompetitionModel rValue = CompetitionDataAccess.GetCompetitionByName(competition.CompetitionName);

            if (rValue == null)
            {
                rValue = CompetitionDataAccess.InsertCompetition(competition);
            }

            return(rValue);
        }
Beispiel #3
0
        /// <summary>
        /// Create a Player
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public static PlayerModel GetOrCreatePlayer(PlayerModel player)
        {
            PlayerModel rValue = CompetitionDataAccess.GetPlayer(player.PlayerName);

            if (rValue == null)
            {
                rValue = CompetitionDataAccess.InsertPlayer(player);
            }

            return(rValue);
        }
Beispiel #4
0
 /// <summary>
 /// Get a list of registered Players.
 /// </summary>
 /// <param name="competitionID"></param>
 /// <returns></returns>
 public static List <PlayerModel> GetRegisteredPlayers(long competitionID)
 => CompetitionDataAccess.GetRegisteredPlayers(competitionID);
Beispiel #5
0
 /// <summary>
 /// Given a CompetitionName, returns the CompetitionID (if it exists in the database), or -1 if it doesn't.
 /// </summary>
 /// <param name="competitionName"></param>
 /// <returns></returns>
 private static long GetCompetitionID(string competitionName)
 => CompetitionDataAccess.GetCompetitionID(competitionName);
Beispiel #6
0
 /// <summary>
 /// Get all Competitions from the database.
 /// </summary>
 /// <param name="excludeDeleted"></param>
 /// <returns></returns>
 public static List <CompetitionModel> GetAllCompetitions(bool excludeDeleted = false)
 => CompetitionDataAccess.GetAllCompetitions(excludeDeleted);
Beispiel #7
0
 public static void RegisterTeam(long competitionID, long player1ID, long player2ID)
 => CompetitionDataAccess.InsertTeam(competitionID, player1ID, player2ID);
Beispiel #8
0
 public static void RegisterPlayer(long competitionID, long playerID, bool regular = true)
 {
     CompetitionDataAccess.InsertPlayerToCompetition(competitionID, playerID, regular);
 }