diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 9384c41..5e91972 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -422,6 +422,7 @@ namespace ManagerService.Controllers configuration = new Configuration(); configuration.Id = exportConfiguration.id; + configuration.InstanceId = exportConfiguration.instanceId; configuration.Label = exportConfiguration.label; configuration.Title = exportConfiguration.title; configuration.ImageId = exportConfiguration.imageId; @@ -446,6 +447,7 @@ namespace ManagerService.Controllers { Section newSection = new Section(); newSection.Id = section.id; + newSection.InstanceId = section.instanceId; newSection.Label = section.label; newSection.Title = section.title; newSection.Description = section.description; @@ -580,6 +582,7 @@ namespace ManagerService.Controllers { Resource resource = new Resource(); resource.Id = resourceExport.id; + resource.InstanceId = resourceExport.instanceId; resource.Type = resourceExport.type; resource.Label = resourceExport.label; resource.DateCreation = resourceExport.dateCreation; diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index e124531..85d61bc 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -27,13 +27,15 @@ namespace ManagerService.Controllers { private ResourceDatabaseService _resourceService; private SectionDatabaseService _sectionService; + private ConfigurationDatabaseService _configurationService; private readonly ILogger _logger; - public ResourceController(ILogger logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService) + public ResourceController(ILogger logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService) { _logger = logger; _resourceService = resourceService; _sectionService = sectionService; + _configurationService = configurationService; } /// @@ -297,6 +299,16 @@ namespace ManagerService.Controllers throw new KeyNotFoundException("Resource does not exist"); + foreach (var configuration in _configurationService.GetAll(ressource.InstanceId)) + { + if (configuration.ImageId == id) + { + configuration.ImageId = null; + configuration.ImageSource = null; + } + } + + // Delete all resource occurence foreach (var section in _sectionService.GetAll(ressource.InstanceId)) {