diff --git a/src/AzureIoTHub.Portal/Client/Pages/Gateways/CreateGatewayDialog.razor b/src/AzureIoTHub.Portal/Client/Pages/Gateways/CreateGatewayDialog.razor
index 1b0d34ecb..5cd1a7282 100644
--- a/src/AzureIoTHub.Portal/Client/Pages/Gateways/CreateGatewayDialog.razor
+++ b/src/AzureIoTHub.Portal/Client/Pages/Gateways/CreateGatewayDialog.razor
@@ -26,7 +26,7 @@
Placeholder="Please select the type"
Required="true"
AdornmentColor="Color.Primary">
- LoRa Device
+ LoRa Device
Other
diff --git a/src/AzureIoTHub.Portal/Server/Controllers/GatewaysController.cs b/src/AzureIoTHub.Portal/Server/Controllers/GatewaysController.cs
index ef5ef8d18..26b57a043 100644
--- a/src/AzureIoTHub.Portal/Server/Controllers/GatewaysController.cs
+++ b/src/AzureIoTHub.Portal/Server/Controllers/GatewaysController.cs
@@ -57,23 +57,37 @@ public GatewaysController(
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))]
public async Task Get()
{
- // don't contain properties
- IEnumerable devicesWithoutProperties = await this.devicesService.GetAllEdgeDeviceWithTags();
- // don't contain connected device
- IEnumerable edgeDevices = await this.devicesService.GetAllEdgeDevice();
+ try
+ {
+ // don't contain tags
+ IEnumerable edgeDevices = await this.devicesService.GetAllEdgeDevice();
- List newGatewayList = new ();
- int index = 0;
+ List newGatewayList = new ();
- newGatewayList.AddRange(edgeDevices.Select(deviceTwin => new GatewayListItem
- {
- DeviceId = deviceTwin.DeviceId,
- Status = deviceTwin.Status?.ToString(),
- Type = DeviceHelper.RetrieveTagValue(devicesWithoutProperties.ElementAt(index++), "purpose"),
- NbDevices = DeviceHelper.RetrieveConnectedDeviceCount(deviceTwin)
- }));
+ foreach (Twin deviceTwin in edgeDevices)
+ {
+ var twin = this.devicesService.GetDeviceTwin(deviceTwin.DeviceId).Result;
- return this.Ok(newGatewayList);
+ if (twin != null)
+ {
+ GatewayListItem gateway = new ()
+ {
+ DeviceId = deviceTwin.DeviceId,
+ Status = deviceTwin.Status?.ToString(),
+ Type = DeviceHelper.RetrieveTagValue(twin, "purpose"),
+ NbDevices = DeviceHelper.RetrieveConnectedDeviceCount(deviceTwin)
+ };
+
+ newGatewayList.Add(gateway);
+ }
+ }
+
+ return this.Ok(newGatewayList);
+ }
+ catch (Exception e)
+ {
+ return this.BadRequest(e.Message);
+ }
}
///
@@ -97,9 +111,7 @@ public async Task Get(string deviceId)
Status = deviceTwin.Status?.ToString(),
EndPoint = this.configuration["IoTDPS:ServiceEndpoint"],
Scope = deviceTwin.DeviceScope,
- Connection_state = deviceTwin.ConnectionState?.ToString(),
- // we retrieve the symmetric Key
- // SymmetricKey = DeviceHelper.RetrieveSymmetricKey(deviceTwin.DeviceId, this.devicesService.GetDpsAttestionMechanism().Result),
+ Connection_state = deviceTwin.ConnectionState.Value.ToString(),
// We retrieve the values of tags
Type = DeviceHelper.RetrieveTagValue(deviceTwin, "purpose"),
Environment = DeviceHelper.RetrieveTagValue(deviceTwin, "env"),