From e246d2ff5b3f97f0fd0387d8e06bf33cfc981cee Mon Sep 17 00:00:00 2001 From: Kevin BEAUGRAND <9513635+kbeaugrand@users.noreply.github.com> Date: Wed, 26 Jan 2022 16:55:18 +0100 Subject: [PATCH] fix #102 - Check if device model is present before requesting the current device model (#105) --- .../Client/Pages/Devices/DeviceDetailPage.razor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceDetailPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceDetailPage.razor index 64e6d736c..22dc3ebc2 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceDetailPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceDetailPage.razor @@ -184,8 +184,11 @@ Device = await Http.GetFromJsonAsync($"api/Devices/{DeviceID}"); // Gets the DeviceModel Name from the DeviceModel ID - DeviceModel model = await Http.GetFromJsonAsync($"api/DeviceModels/{Device.ModelId}"); - Device.ModelName = model.Name; + if (!string.IsNullOrEmpty(Device.ModelId)) + { + DeviceModel model = await Http.GetFromJsonAsync($"api/DeviceModels/{Device.ModelId}"); + Device.ModelName = model?.Name; + } // StatusUpdatedTime set to string to have a more human-readable format StatusUpdatedTimeString = Device.StatusUpdatedTime.ToString();