Example #1
0
        public bool AddPlayerToGroup(int groupid, string username)
        {
            AccountContext accountContext = new AccountContext();
            Player         existingPlayer = accountContext.GetPlayerByUsername(username);

            if (existingPlayer != null && !context.IsPlayerInGroup(existingPlayer.ID, groupid))
            {
                context.AddPlayer(groupid, existingPlayer.ID);
                return(true);
            }

            return(false);
        }
Example #2
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>());
            }
        }