diff --git a/src/AzureIoTHub.Portal.Client/Pages/EdgeModels/EdgeModelDetailPage.razor b/src/AzureIoTHub.Portal.Client/Pages/EdgeModels/EdgeModelDetailPage.razor index 342939f02..3edd489be 100644 --- a/src/AzureIoTHub.Portal.Client/Pages/EdgeModels/EdgeModelDetailPage.razor +++ b/src/AzureIoTHub.Portal.Client/Pages/EdgeModels/EdgeModelDetailPage.razor @@ -62,7 +62,7 @@ - + diff --git a/src/AzureIoTHub.Portal.Infrastructure/Services/EdgeModelService.cs b/src/AzureIoTHub.Portal.Infrastructure/Services/EdgeModelService.cs index 427f1ae63..2c84c222d 100644 --- a/src/AzureIoTHub.Portal.Infrastructure/Services/EdgeModelService.cs +++ b/src/AzureIoTHub.Portal.Infrastructure/Services/EdgeModelService.cs @@ -253,20 +253,21 @@ public async Task UpdateEdgeModel(IoTEdgeModel edgeModel) foreach (var labelEntity in edgeModelEntity.Labels) { this.labelRepository.Delete(labelEntity.Id); - } - + } + + edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel); + + _ = this.mapper.Map(edgeModel, edgeModelEntity); + + this.edgeModelRepository.Update(edgeModelEntity); + // For AWS, we do the update in the AwsConfiguration if (this.config.CloudProvider.Equals(CloudProviders.Azure, StringComparison.Ordinal)) { - _ = this.mapper.Map(edgeModel, edgeModelEntity); - - this.edgeModelRepository.Update(edgeModelEntity); - - await SaveModuleCommands(edgeModel); + await SaveModuleCommands(edgeModel); + } - - edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel); await this.unitOfWork.SaveAsync(); } diff --git a/src/AzureIoTHub.Portal.Tests.Unit/Server/Services/EdgeModelServiceTest.cs b/src/AzureIoTHub.Portal.Tests.Unit/Server/Services/EdgeModelServiceTest.cs index 1e6aeb8b8..3738e5e99 100644 --- a/src/AzureIoTHub.Portal.Tests.Unit/Server/Services/EdgeModelServiceTest.cs +++ b/src/AzureIoTHub.Portal.Tests.Unit/Server/Services/EdgeModelServiceTest.cs @@ -404,6 +404,10 @@ public async Task UpdateEdgeModelForAWSShouldUpdateEdgeModel() this.mockLabelRepository.Setup(repository => repository.Delete(It.IsAny())) .Verifiable(); + _ = this.mockEdgeDeviceModelRepository.Setup(repository => repository.Update(It.IsAny())); + _ = this.mockUnitOfWork.Setup(work => work.SaveAsync()) + .Returns(Task.CompletedTask); + _ = this.mockConfigService.Setup(x => x.RollOutEdgeModelConfiguration(It.IsAny())) .Returns(Task.FromResult(Fixture.Create()));