Adds updating of SortOrder upon moving a document.

Related to U4-1461
This commit is contained in:
Morten Christensen
2013-01-14 14:04:40 -01:00
parent 886678786b
commit bc23495632
2 changed files with 9 additions and 3 deletions

View File

@@ -280,6 +280,8 @@ namespace Umbraco.Core.Persistence.Repositories
{
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
entity.Path = string.Concat(parent.Path, ",", entity.Id);
var maxSortOrder = Database.ExecuteScalar<int>("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId });
entity.SortOrder = maxSortOrder;
}
var factory = new ContentFactory(NodeObjectTypeId, entity.Id);

View File

@@ -905,9 +905,13 @@ namespace Umbraco.Core.Services
/// <param name="userId">Optional Id of the User moving the Content</param>
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<IContent>(content, parentId), this))
return;