Esempio n. 1
0
        /// <summary>
        /// Returns string Array with all the usernames registrated.
        /// If you send an groupid with it you'll get a list of all players except the once that are already in the group.
        /// </summary>
        /// <param name="groupid"></param>
        /// <returns></returns>
        public string[] GetAddPlayerName(int?groupid)
        {
            AccountContext accountContext = new AccountContext();
            GroupContext   groupContext   = new GroupContext();

            if (groupid != null)
            {
                List <string> usernames = new List <string>();

                foreach (string username in accountContext.GetAllPlayers())
                {
                    if (!groupContext.IsPlayerInGroup(accountContext.GetPlayerByUsername(username).ID, (int)groupid))
                    {
                        usernames.Add(username);
                    }
                }

                return(usernames.ToArray <string>());
            }
            else
            {
                return(accountContext.GetAllPlayers().ToArray <string>());
            }
        }