Update to CreatePackage API endpoint - the ID & Guid was getting overwritten by mistake

This commit is contained in:
Warren Buckley
2018-12-07 09:29:44 +00:00
parent 7f380347dc
commit a9aba6731d

View File

@@ -38,10 +38,16 @@ namespace Umbraco.Web.Editors
[HttpPost]
public PackageInstance PostCreatePackage(PackageInstance model)
{
var newPackage = CreatedPackage.MakeNew(model.Name);
newPackage.Data = model;
var packageId = newPackage.Data.Id;
var packageGuid = newPackage.Data.PackageGuid;
//Need to reset the package ID - as the posted model the package ID is always 0
//MakeNew will init create the XML & update the file and give us an ID to use
newPackage.Data = model;
newPackage.Data.Id = packageId;
newPackage.Data.PackageGuid = packageGuid;
//TODO Validation on the model?!
//Save then publish