diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index c798a927dd..0671b4c150 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -280,6 +280,8 @@ namespace Umbraco.Core.Persistence.Repositories { var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); entity.Path = string.Concat(parent.Path, ",", entity.Id); + var maxSortOrder = Database.ExecuteScalar("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId }); + entity.SortOrder = maxSortOrder; } var factory = new ContentFactory(NodeObjectTypeId, entity.Id); diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index e9ce6983cf..50c9eaef9a 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -905,9 +905,13 @@ namespace Umbraco.Core.Services /// Optional Id of the User moving the Content public void Move(IContent content, int parentId, int userId = -1) { - //TODO Verify that SortOrder + Path is updated correctly - //TODO Add a check to see if parentId = -20 because then we should change the TrashState - + //This ensures that the correct method is called if this method is used to Move to recycle bin. + if (parentId == -20) + { + MoveToRecycleBin(content, userId); + return; + } + if (Moving.IsRaisedEventCancelled(new MoveEventArgs(content, parentId), this)) return;