Merge branch 'refs/heads/temp-u4-8937' into dev-v7
This commit is contained in:
@@ -467,7 +467,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the sort order for media
|
||||
/// Change the sort order for content
|
||||
/// </summary>
|
||||
/// <param name="sorted"></param>
|
||||
/// <returns></returns>
|
||||
@@ -485,23 +485,33 @@ namespace Umbraco.Web.Editors
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
var contentService = Services.ContentService;
|
||||
var sortedContent = new List<IContent>();
|
||||
try
|
||||
{
|
||||
sortedContent.AddRange(Services.ContentService.GetByIds(sorted.IdSortOrder));
|
||||
var contentService = Services.ContentService;
|
||||
|
||||
// content service GetByIds does *not* order the content items
|
||||
// so we need get them in the proper order here - no need to sort!
|
||||
var content = contentService
|
||||
.GetByIds(sorted.IdSortOrder)
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
var sortedContent = sorted.IdSortOrder.Select(x =>
|
||||
{
|
||||
IContent c;
|
||||
return content.TryGetValue(x, out c) ? c : null;
|
||||
}).WhereNotNull();
|
||||
|
||||
// Save content with new sort order and update content xml in db accordingly
|
||||
if (contentService.Sort(sortedContent) == false)
|
||||
{
|
||||
LogHelper.Warn<MediaController>("Content sorting failed, this was probably caused by an event being cancelled");
|
||||
LogHelper.Warn<ContentController>("Content sorting failed, this was probably caused by an event being cancelled");
|
||||
return Request.CreateValidationErrorResponse("Content sorting failed, this was probably caused by an event being cancelled");
|
||||
}
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<MediaController>("Could not update content sort order", ex);
|
||||
LogHelper.Error<ContentController>("Could not update content sort order", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user