public void DeleteTitle(UserTitleViewModel title)
 {
     this.Titles.Remove(title);
     ChannelSession.Settings.UserTitles.Remove(title.Title);
     this.RefreshTitleList();
 }
        public UsersSettingsControlViewModel()
        {
            this.ExplicitUserRoleRequirements = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.ExplicitUserRoleRequirements,
                                                                                                ChannelSession.Settings.ExplicitUserRoleRequirements, (value) => { ChannelSession.Settings.ExplicitUserRoleRequirements = value; }, MixItUp.Base.Resources.ExplicitUserRoleRequirementsTooltip);

            this.ClearMixerUserData = new GenericButtonSettingsOptionControlViewModel(MixItUp.Base.Resources.ClearMixerUserDataHeader, MixItUp.Base.Resources.ClearMixerUserData, this.CreateCommand(async(parameter) =>
            {
                if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.ClearAllMixerUserDataWarning))
                {
                    ChannelSession.Settings.ClearMixerUserData();
                    await ChannelSession.SaveSettings();
                    GlobalEvents.RestartRequested();
                }
            }));

            this.ClearUserData = new GenericButtonSettingsOptionControlViewModel(MixItUp.Base.Resources.ClearAllUserDataHeader, MixItUp.Base.Resources.ClearUserData, this.CreateCommand(async(parameter) =>
            {
                if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.ClearAllUserDataWarning))
                {
                    await ChannelSession.Settings.ClearAllUserData();
                    await ChannelSession.SaveSettings();
                    GlobalEvents.RestartRequested();
                }
            }));

            this.RefreshTitleList();

            this.AddCommand = this.CreateCommand(async(parameter) =>
            {
                if (string.IsNullOrEmpty(this.TitleName))
                {
                    await DialogHelper.ShowMessage(Resources.CreateTitleErrorNoTitle);
                    return;
                }

                if (this.CanSelectMinimumMonths && this.MinimumMonths < 0)
                {
                    await DialogHelper.ShowMessage(Resources.CreateTitleErrorInvalidMonths);
                    return;
                }

                if (this.Titles.Any(t => t.Name.Equals(this.TitleName)))
                {
                    await DialogHelper.ShowMessage(Resources.CreateTitleErrorDuplicateTitle);
                    return;
                }

                UserTitleViewModel existingTitle = this.Titles.FirstOrDefault(t => t.Role.Equals(this.SelectedRole));
                if (existingTitle != null)
                {
                    if (existingTitle.Role == UserRoleEnum.Follower || existingTitle.Role == UserRoleEnum.Subscriber)
                    {
                        if (existingTitle.Months == this.MinimumMonths)
                        {
                            await DialogHelper.ShowMessage(Resources.CreateTitleErrorDuplicateRoleMonths);
                            return;
                        }
                    }
                    else
                    {
                        await DialogHelper.ShowMessage(Resources.CreateTitleErrorDuplicateRole);
                        return;
                    }
                }

                ChannelSession.Settings.UserTitles.Add(new UserTitleModel(this.TitleName, this.SelectedRole, this.MinimumMonths));
                this.RefreshTitleList();
            });
        }