import => support instanceId + Delete resource, delete imageId and ref for configuration

This commit is contained in:
Fransolet Thomas 2022-10-21 17:38:17 +02:00
parent 499065bdb7
commit 390852ce4f
2 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -27,13 +27,15 @@ namespace ManagerService.Controllers
{
private ResourceDatabaseService _resourceService;
private SectionDatabaseService _sectionService;
private ConfigurationDatabaseService _configurationService;
private readonly ILogger<ResourceController> _logger;
public ResourceController(ILogger<ResourceController> logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService)
public ResourceController(ILogger<ResourceController> logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService)
{
_logger = logger;
_resourceService = resourceService;
_sectionService = sectionService;
_configurationService = configurationService;
}
/// <summary>
@ -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))
{