From 90416a4d879e93f2c7dc69532597a6cb67c10b3f Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Fri, 12 Oct 2018 08:34:33 +0200 Subject: [PATCH] Add a custom content item binder for saving blueprints (fixes #2985) --- src/Umbraco.Web/Editors/ContentController.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 1 + .../WebApi/Binders/BlueprintItemBinder.cs | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Web/WebApi/Binders/BlueprintItemBinder.cs diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 6268759e29..4643cb2a1e 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -576,7 +576,7 @@ namespace Umbraco.Web.Editors [FileUploadCleanupFilter] [ContentPostValidate] public ContentItemDisplay PostSaveBlueprint( - [ModelBinder(typeof(ContentItemBinder))] ContentItemSave contentItem) + [ModelBinder(typeof(BlueprintItemBinder))] ContentItemSave contentItem) { var contentItemDisplay = PostSaveInternal(contentItem, content => diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 66cce9b1bf..e021de0011 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -823,6 +823,7 @@ + diff --git a/src/Umbraco.Web/WebApi/Binders/BlueprintItemBinder.cs b/src/Umbraco.Web/WebApi/Binders/BlueprintItemBinder.cs new file mode 100644 index 0000000000..825c5b01c3 --- /dev/null +++ b/src/Umbraco.Web/WebApi/Binders/BlueprintItemBinder.cs @@ -0,0 +1,28 @@ +using System; +using Umbraco.Core; +using Umbraco.Core.Models; +using Umbraco.Web.Models.ContentEditing; + +namespace Umbraco.Web.WebApi.Binders +{ + internal class BlueprintItemBinder : ContentItemBinder + { + public BlueprintItemBinder(ApplicationContext applicationContext) + : base(applicationContext) + { + } + + /// + /// Constructor + /// + public BlueprintItemBinder() + : this(ApplicationContext.Current) + { + } + + protected override IContent GetExisting(ContentItemSave model) + { + return ApplicationContext.Services.ContentService.GetBlueprintById(Convert.ToInt32(model.Id)); + } + } +} \ No newline at end of file