public TreeNode[] ToTree()
        {
            var nodes = new List <TreeNode>();

            nodes.Add(Blufor.ToTree());

            if (Opfor != null)
            {
                nodes.Add(Opfor.ToTree());
            }

            if (SpecialRoles != null)
            {
                nodes.Add(SpecialRoles.ToTree());
            }

            if (ExtraPlayers != null)
            {
                nodes.Add(ExtraPlayers.ToTree());
            }

            if (Zeus != null)
            {
                nodes.Add(Zeus.ToTree());
            }

            return(nodes.ToArray());
        }
        public async Task <CachedRole> GetSpecialRoleAsync(ulong guildId, RoleType type)
        {
            if (!(await SpecialRoles.FindAsync(guildId, type) is { } role))
            {
                return(null);
            }

            return(_client.GetGuild(guildId).GetRole(role.Id));
        }
        /// <summary>
        /// Get list of roles which can access the document with given id.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <returns></returns>
        public static string GetDocumentRoles(int itemId)
        {
            if (itemId == 0)
            {
                return(string.Empty);
            }

            // Create Instance of Connection and Command Object
            SqlConnection myConnection = Config.SqlConnectionString;
            SqlCommand    myCommand    = new SqlCommand("rb_GetSingleSecureDocumentRoles", myConnection);

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            // Add Parameters to SPROC
            SqlParameter parameteritemId = new SqlParameter("@itemId", SqlDbType.Int, 4);

            parameteritemId.Value = itemId;
            myCommand.Parameters.Add(parameteritemId);

            // Execute the command
            myConnection.Open();
            SqlDataReader drGetRoles = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
            string        result     = string.Empty;

            try
            {
                while (drGetRoles.Read())
                {
                    // if the role name is null, its a special case
                    // so we need to do a look up on it to get its name
                    if (drGetRoles["RoleName"] == DBNull.Value)
                    {
                        result += SpecialRoles.GetRoleName(int.Parse(drGetRoles["GroupID"].ToString())) + ";";
                    }

                    // otherwise use the role name from the table
                    else
                    {
                        result += drGetRoles["RoleName"].ToString() + ";";
                    }
                }
            }
            finally
            {
                drGetRoles.Close();
                myConnection.Close();
            }

            // Return the datareader
            return(result);
        }
 public async Task <SpecialRoles> UpdateSpecialRole(SpecialRoles entity)
 {
     return(await _specialRoles.Update(entity));
 }