Skip to content

Commit

Permalink
Return specified field for orderByDescending= query
Browse files Browse the repository at this point in the history
  • Loading branch information
griffri committed Oct 11, 2024
1 parent 549bdf4 commit 45ce8d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public async Task<IActionResult> Get(int customerId, string id, int? page = 1, i

if (Request.ShowExtraProperties())
{
var orderByParameter = orderByField != null
? $"{(descending ? "orderByDescending" : "orderBy")}={orderByField}"
: null;

return Ok(storageRoot.Collection.ToFlatCollection(GetUrlRoots(), pageSize.Value, page.Value,
storageRoot.TotalItems, storageRoot.Items, orderByField));
storageRoot.TotalItems, storageRoot.Items, orderByParameter));
}

return SeeOther(storageRoot.Collection.GenerateHierarchicalCollectionId(GetUrlRoots()));
Expand Down
4 changes: 2 additions & 2 deletions src/IIIFPresentation/API/Infrastructure/ControllerBaseX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public static ObjectResult ValidationFailed(this ControllerBase controller, Vali
descending = false;
if (orderBy.HasText() && OrderByHelper.AllowedOrderByFields.Contains(orderBy.ToLower()))
{
orderByField = $"orderBy={orderBy}";
orderByField = orderBy;
}
else if (orderByDescending.HasText() && OrderByHelper.AllowedOrderByFields.Contains(orderByDescending.ToLower()))
{
orderByField = $"orderByDescending={orderByDescending}";
orderByField = orderByDescending;
descending = true;
}

Expand Down

0 comments on commit 45ce8d5

Please sign in to comment.