Пример #1
0
        public override async Task <IDisplayResult> UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context)
        {
            var settings = new DictionaryFieldSettings();

            if (await context.Updater.TryUpdateModelAsync(settings, Prefix))
            {
                // This makes sure the JSON is correctly formatted as it comes from the front end
                // with incorrect casing
                settings.DefaultData = JsonConvert.SerializeObject(JsonConvert.DeserializeObject <IList <DictionaryItem> >(settings.DefaultData));
                context.Builder.MergeSettings(settings);
            }

            return(Edit(partFieldDefinition));
        }
Пример #2
0
        public override async Task <IDisplayResult> UpdateAsync(ContentPartFieldDefinition model, UpdatePartFieldEditorContext context)
        {
            var settings = new DictionaryFieldSettings();

            if (await context.Updater.TryUpdateModelAsync(settings, Prefix))
            {
                // This makes sure the JSON is correctly formatted as it comes from the front end
                // with incorrect casing
                try
                {
                    settings.DefaultData = JsonConvert.SerializeObject(JsonConvert.DeserializeObject <IList <DictionaryItem> >(settings.DefaultData));
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Error parsing DefaultData for DictionaryFieldSettings");
                }

                context.Builder.WithSettings(settings);
            }

            return(Edit(model));
        }