public void DeleteTitle(UserTitleViewModel title)
 {
     this.Titles.Remove(title);
     ChannelSession.Settings.UserTitles.Remove(title.Title);
     this.RefreshTitleList();
 }
        public UsersSettingsControlViewModel()
        {
            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("A name for the title must be specified");
                    return;
                }

                if (this.CanSelectMinimumMonths && this.MinimumMonths < 0)
                {
                    await DialogHelper.ShowMessage("A valid amount of months for the title must be specified");
                    return;
                }

                if (this.Titles.Any(t => t.Name.Equals(this.TitleName)))
                {
                    await DialogHelper.ShowMessage("A title with the same name already exists");
                    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("A title with the same role & months already exists");
                            return;
                        }
                    }
                    else
                    {
                        await DialogHelper.ShowMessage("A title with the same role already exists");
                        return;
                    }
                }

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