diff --git a/src/Umbraco.Infrastructure/Services/Implement/ContentTypeServiceBaseOfTRepositoryTItemTService.cs b/src/Umbraco.Infrastructure/Services/Implement/ContentTypeServiceBaseOfTRepositoryTItemTService.cs index 21f95f74d6..86270cbcb3 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/ContentTypeServiceBaseOfTRepositoryTItemTService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/ContentTypeServiceBaseOfTRepositoryTItemTService.cs @@ -730,7 +730,7 @@ namespace Umbraco.Cms.Core.Services.Implement public Attempt> Copy(TItem copying, int containerId) { - var evtMsgs = EventMessagesFactory.Get(); + var eventMessages = EventMessagesFactory.Get(); TItem copy; using (var scope = ScopeProvider.CreateScope()) @@ -765,16 +765,34 @@ namespace Umbraco.Cms.Core.Services.Implement } copy.ParentId = containerId; + + SavingNotification savingNotification = GetSavingNotification(copy, eventMessages); + if (scope.Notifications.PublishCancelable(savingNotification)) + { + scope.Complete(); + return OperationResult.Attempt.Fail(MoveOperationStatusType.FailedCancelledByEvent, eventMessages, copy); + } + Repository.Save(copy); + + ContentTypeChange[] changes = ComposeContentTypeChanges(copy).ToArray(); + + _eventAggregator.Publish(GetContentTypeRefreshedNotification(changes, eventMessages)); + scope.Notifications.Publish(GetContentTypeChangedNotification(changes, eventMessages)); + + SavedNotification savedNotification = GetSavedNotification(copy, eventMessages); + savedNotification.WithStateFrom(savingNotification); + scope.Notifications.Publish(savedNotification); + scope.Complete(); } catch (DataOperationException ex) { - return OperationResult.Attempt.Fail(ex.Operation, evtMsgs); // causes rollback + return OperationResult.Attempt.Fail(ex.Operation, eventMessages); // causes rollback } } - return OperationResult.Attempt.Succeed(MoveOperationStatusType.Success, evtMsgs, copy); + return OperationResult.Attempt.Succeed(MoveOperationStatusType.Success, eventMessages, copy); } #endregion