Skip to content

Commit

Permalink
resolve #1372
Browse files Browse the repository at this point in the history
  • Loading branch information
Sben65 committed Oct 19, 2022
1 parent cb50293 commit 7133485
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace AzureIoTHub.Portal.Tests.Unit.Server.Controllers.v10
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Azure.Devices.Common.Exceptions;
using Microsoft.Extensions.Logging;
using Models.v10;
Expand Down Expand Up @@ -78,6 +79,12 @@ public async Task GetAllDeviceShouldReturnOkResult()
It.IsAny<string[]>()))
.ReturnsAsync(expectedPaginedEdgeDevice);

var locationUrl = "http://location/edge/devices";

_ = this.mockUrlHelper
.Setup(x => x.RouteUrl(It.IsAny<UrlRouteContext>()))
.Returns(locationUrl);

// Act
var result = await edgeDeviceController.Get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Azure.Devices.Common.Exceptions;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -58,7 +60,6 @@ public EdgeDevicesController(
/// </summary>
/// <param name="searchText"></param>
/// <param name="searchStatus"></param>
/// <param name="searchType"></param>
/// <param name="pageSize"></param>
/// <param name="pageNumber"></param>
/// <param name="orderBy"></param>
Expand All @@ -78,12 +79,29 @@ public async Task<PaginationResult<IoTEdgeListItem>> Get(
pageNumber,
orderBy);

var nextPage = string.Empty;

if (paginatedEdgeDevices.HasNextPage)
{
nextPage = Url.RouteUrl(new UrlRouteContext
{
RouteName = "GET IoT Edge devices",
Values = new
{
searchText,
searchStatus,
pageSize,
pageNumber = pageNumber + 1,
orderBy
}
});
}

return new PaginationResult<IoTEdgeListItem>
{
Items = paginatedEdgeDevices.Data,
TotalItems = paginatedEdgeDevices.TotalCount,
//NextPage = nextPage
NextPage = nextPage
};
}

Expand Down

0 comments on commit 7133485

Please sign in to comment.