diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index e723bfcdd2..8bdaba271e 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -2448,22 +2448,26 @@ public class ContentService : RepositoryService, IContentService
/// The to move
/// Id of the Content's new Parent
/// Optional Id of the User moving the Content
- public void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId)
+ public void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId) =>
+ AttemptMove(content, parentId, userId);
+
+ ///
+ [Obsolete("Adds return type to Move method. Will be removed in V14, as the original method will be adjusted.")]
+ public OperationResult AttemptMove(IContent content, int parentId, int userId = Constants.Security.SuperUserId)
{
+ EventMessages eventMessages = EventMessagesFactory.Get();
+
if (content.ParentId == parentId)
{
- return;
+ return OperationResult.Succeed(eventMessages);
}
// if moving to the recycle bin then use the proper method
if (parentId == Constants.System.RecycleBinContent)
{
- MoveToRecycleBin(content, userId);
- return;
+ return MoveToRecycleBin(content, userId);
}
- EventMessages eventMessages = EventMessagesFactory.Get();
-
var moves = new List<(IContent, string)>();
using (ICoreScope scope = ScopeProvider.CreateCoreScope())
@@ -2482,7 +2486,7 @@ public class ContentService : RepositoryService, IContentService
if (scope.Notifications.PublishCancelable(movingNotification))
{
scope.Complete();
- return; // causes rollback
+ return OperationResult.Cancel(eventMessages);// causes rollback
}
// if content was trashed, and since we're not moving to the recycle bin,
@@ -2517,6 +2521,8 @@ public class ContentService : RepositoryService, IContentService
scope.Complete();
}
+
+ return OperationResult.Succeed(eventMessages);
}
// MUST be called from within WriteLock
diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index 0d3cc80b82..1733a74142 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -1,3 +1,4 @@
+using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
@@ -315,6 +316,21 @@ public interface IContentService : IContentServiceBase
///
void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId);
+ ///
+ /// Attempts to move the to under the node with id .
+ ///
+ /// The that shall be moved.
+ /// The id of the new parent node.
+ /// Id of the user attempting to move .
+ /// Success if moving succeeded, otherwise Failed.
+ [Obsolete("Adds return type to Move method. Will be removed in V14, as the original method will be adjusted.")]
+ OperationResult
+ AttemptMove(IContent content, int parentId, int userId = Constants.Security.SuperUserId)
+ {
+ Move(content, parentId, userId);
+ return OperationResult.Succeed(new EventMessages());
+ }
+
///
/// Copies a document.
///
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
index 81b37bb108..62cbae3012 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
@@ -2254,7 +2254,12 @@ public class ContentController : ContentControllerBase
return null;
}
- _contentService.Move(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity?.GetUserId().Result ?? -1);
+ OperationResult moveResult = _contentService.AttemptMove(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity?.GetUserId().Result ?? -1);
+
+ if (!moveResult.Success)
+ {
+ return ValidationProblem();
+ }
return Content(toMove.Path, MediaTypeNames.Text.Plain, Encoding.UTF8);
}