Adds a Create/Publish method - will need to figure out validation

This commit is contained in:
Warren Buckley
2018-12-06 10:18:31 +00:00
parent cd8bb8ed99
commit de86dace70

View File

@@ -8,6 +8,8 @@ using Umbraco.Web.WebApi.Filters;
namespace Umbraco.Web.Editors
{
//TODO: Packager stuff still lives in business logic - YUK
/// <summary>
/// A controller used for installing packages and managing all of the data in the packages section in the back office
/// </summary>
@@ -18,23 +20,8 @@ namespace Umbraco.Web.Editors
[HttpGet]
public List<CreatedPackage> GetCreatedPackages()
{
//TODO: Packager stuff still lives in business logic - YUK
//TODO: Could be too much data down the wire
return CreatedPackage.GetAllCreatedPackages();
/*
* "author": "Test",
"files": [],
"iconUrl": "",
"id": 1,
"license": "MIT License",
"licenseUrl": "http://opensource.org/licenses/MIT",
"name": "Test v8",
"url": "https://test.com",
"version": "0.0.0"
*/
}
[HttpGet]
@@ -43,6 +30,23 @@ namespace Umbraco.Web.Editors
return CreatedPackage.GetById(id);
}
[HttpPost]
public CreatedPackage PostCreatePackage(PackageInstance model)
{
//TODO Validation on the model?!
var newPackage = new CreatedPackage
{
Data = model
};
//Save then publish
newPackage.Save();
newPackage.Publish();
//We should have packagepath populated now
return newPackage;
}
[HttpDelete]
public HttpResponseMessage DeleteCreatedPackageById(int id)
{