This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from kasparboelkjeldsen/feature/custom-bluepr…
…int-endpoints Feature/custom blueprint endpoints
- Loading branch information
Showing
5 changed files
with
196 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorBlueprintApiController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Net.Mime; | ||
using System.Text.RegularExpressions; | ||
using System.Web.Http; | ||
using System.Web.Http.ModelBinding; | ||
using Our.Umbraco.DocTypeGridEditor.Extensions; | ||
using Our.Umbraco.DocTypeGridEditor.Helpers; | ||
using Our.Umbraco.DocTypeGridEditor.Models; | ||
using Serilog.Core; | ||
using Umbraco.Core; | ||
using Umbraco.Core.Cache; | ||
using Umbraco.Core.Composing.CompositionExtensions; | ||
using Umbraco.Core.Configuration; | ||
using Umbraco.Core.Logging; | ||
using Umbraco.Core.Models; | ||
using Umbraco.Core.Models.PublishedContent; | ||
using Umbraco.Core.Persistence; | ||
using Umbraco.Core.PropertyEditors; | ||
using Umbraco.Core.Scoping; | ||
using Umbraco.Core.Services; | ||
using Umbraco.Web; | ||
using Umbraco.Web.Composing; | ||
using Umbraco.Web.Editors; | ||
using Umbraco.Web.Editors.Binders; | ||
using Umbraco.Web.Models.ContentEditing; | ||
using Umbraco.Web.Mvc; | ||
using Umbraco.Web.PublishedCache; | ||
using Umbraco.Web.Routing; | ||
using Umbraco.Web.WebApi; | ||
using Umbraco.Web.WebApi.Filters; | ||
|
||
|
||
namespace Our.Umbraco.DocTypeGridEditor.Web.Controllers | ||
{ | ||
[PluginController("DocTypeGridEditorApi")] | ||
public class DocTypeGridEditorBlueprintApiController : UmbracoAuthorizedApiController | ||
{ | ||
private readonly IUmbracoContextAccessor _umbracoContext; | ||
private readonly IContentTypeService _contentTypeService; | ||
private readonly IDataTypeService _dataTypeService; | ||
private readonly IPublishedContentCache _contentCache; | ||
private ContentController _contentController; | ||
|
||
public DocTypeGridEditorBlueprintApiController(IUmbracoContextAccessor umbracoContext, | ||
IScopeProvider scopeProvider, | ||
ISqlContext sqlContext, | ||
IProfilingLogger logger, | ||
IRuntimeState runtimeState | ||
) | ||
{ | ||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>())); | ||
_contentController = new ContentController(propertyEditorCollection, GlobalSettings, umbracoContext, sqlContext, Services, AppCaches, logger, runtimeState, Umbraco, scopeProvider); | ||
} | ||
|
||
[FileUploadCleanupFilter] | ||
[HttpPost] | ||
public ContentItemDisplay PostSaveBlueprint([ModelBinder(typeof(BlueprintItemBinder))] ContentItemSave contentItem) | ||
{ | ||
return _contentController.PostSaveBlueprint(contentItem); | ||
} | ||
[HttpDelete] | ||
[HttpPost] | ||
public HttpResponseMessage DeleteBlueprint(int id) | ||
{ | ||
var found = Services.ContentService.GetBlueprintById(id); | ||
|
||
if (found == null) | ||
{ | ||
Request.CreateResponse(HttpStatusCode.BadRequest); | ||
} | ||
|
||
Services.ContentService.DeleteBlueprint(found); | ||
|
||
return Request.CreateResponse(HttpStatusCode.OK); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.