/// <summary>
 /// Create a ViewModel based on the settings provided. This method is really simple to begin
 /// with, to the point where it's not even really needed, but I create it already so that when
 /// the model becomes more complex I don't have to refactor code.
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 private GDPRPartFieldSettingsViewModel MakeViewModel(
     GDPRPartFieldSettings settings, string fieldName)
 {
     return(new GDPRPartFieldSettingsViewModel {
         Settings = settings,
         AnonymizationDivId = AnonymizationDivId(fieldName),
         ErasureDivId = ErasureDivId(fieldName)
     });
 }
 public static void SetValues(ContentPartFieldDefinitionBuilder builder, GDPRPartFieldSettings settings)
 {
     builder.WithSetting(
         "GDPRPartFieldSettings.ShouldAnonymize",
         settings.ShouldAnonymize.ToString(CultureInfo.InvariantCulture));
     builder.WithSetting(
         "GDPRPartFieldSettings.ShouldErase",
         settings.ShouldErase.ToString(CultureInfo.InvariantCulture));
     // serialized dictionaries
     builder.WithSetting(
         "GDPRPartFieldSettings.AnonymizationSerializedPairs",
         settings.AnonymizationSerializedPairs);
     builder.WithSetting(
         "GDPRPartFieldSettings.ErasureSerializedPairs",
         settings.ErasureSerializedPairs);
 }
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (!_typeHasGDPRPart)
            {
                yield break;
            }

            var vm = new GDPRPartFieldSettingsViewModel();

            if (updateModel.TryUpdateModel(vm, "GDPRPartFieldSettingsViewModel", null, null))
            {
                var settings = vm.Settings;
                GDPRPartFieldSettings.SetValues(builder, settings);
            }
            else
            {
                _notifier.Error(T("There was an issue updating the GDPR configuration for {0}.", builder.Name));
                yield break;
            }
        }