예제 #1
0
    /// <summary>
    /// Selector changed.
    /// </summary>
    private void userSelector_Changed(object sender, EventArgs e)
    {
        currentValues = GetModerators();

        // Remove old items
        string newValues = ValidationHelper.GetString(userSelector.CurrentSelector.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                foreach (string item in newItems)
                {
                    int userId = ValidationHelper.GetInteger(item, 0);
                    if (userId > 0)
                    {
                        ForumInfoProvider.RemoveModerator(userId, ForumID);
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to forum
                foreach (string item in newItems)
                {
                    int userId = ValidationHelper.GetInteger(item, 0);
                    if (userId > 0)
                    {
                        ForumInfoProvider.AddModerator(userId, ForumID);
                    }
                }
            }
        }
    }