Add a custom content item binder for saving blueprints (fixes #2985)

This commit is contained in:
Kenn Jacobsen
2018-10-12 08:34:33 +02:00
committed by Sebastiaan Janssen
parent 827bc19f6a
commit d16bc7a465
3 changed files with 30 additions and 1 deletions

View File

@@ -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 =>

View File

@@ -823,6 +823,7 @@
</Compile>
<Compile Include="WebApi\AngularJsonMediaTypeFormatter.cs" />
<Compile Include="WebApi\AngularJsonOnlyConfigurationAttribute.cs" />
<Compile Include="WebApi\Binders\BlueprintItemBinder.cs" />
<Compile Include="WebApi\Binders\MemberBinder.cs" />
<Compile Include="WebApi\EnableDetailedErrorsAttribute.cs" />
<Compile Include="WebApi\Filters\AngularAntiForgeryHelper.cs" />

View File

@@ -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)
{
}
/// <summary>
/// Constructor
/// </summary>
public BlueprintItemBinder()
: this(ApplicationContext.Current)
{
}
protected override IContent GetExisting(ContentItemSave model)
{
return ApplicationContext.Services.ContentService.GetBlueprintById(Convert.ToInt32(model.Id));
}
}
}