Exemplo n.º 1
0
        public override async Task <IDisplayResult> UpdateAsync(ContentPartFieldDefinition model, UpdatePartFieldEditorContext context)
        {
            var viewModel = new UpdateResponsiveMediaFieldSettingsViewModel();

            await context.Updater.TryUpdateModelAsync(viewModel, Prefix);

            var settings = new ResponsiveMediaFieldSettings
            {
                AllowMediaText = viewModel.AllowMediaText,
                Hint           = viewModel.Hint,
                Multiple       = viewModel.Multiple,
                Required       = viewModel.Required,
                FallbackData   = JsonConvert.SerializeObject(ResponsiveMediaUtils.ParseMedia(_mediaFileStore, viewModel.FallbackData))
            };

            try
            {
                settings.Breakpoints = viewModel.Breakpoints;
                settings.GetBreakpoints();
            } catch
            {
                context.Updater.ModelState.AddModelError(Prefix, T["Failed to parse breakpoints, make sure it only contains numeric values."]);
            }

            context.Builder.WithSettings(settings);

            return(Edit(model));
        }
Exemplo n.º 2
0
        public override async Task <IDisplayResult> UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context)
        {
            var model = new UpdateResponsiveMediaFieldSettingsViewModel();

            await context.Updater.TryUpdateModelAsync(model, Prefix);

            var settings = new ResponsiveMediaFieldSettings
            {
                Hint     = model.Hint,
                Required = model.Required
            };

            try
            {
                settings.Breakpoints = model.Breakpoints;
                settings.GetBreakpoints();
            } catch
            {
                context.Updater.ModelState.AddModelError(Prefix, T["Failed to parse breakpoints, make sure it only contains numeric values."]);
            }

            context.Builder.MergeSettings(settings);

            return(Edit(partFieldDefinition));
        }