diff --git a/code/Executable/Controllers/ConfigurationController.cs b/code/Executable/Controllers/ConfigurationController.cs index be1d8a8d..45881c55 100644 --- a/code/Executable/Controllers/ConfigurationController.cs +++ b/code/Executable/Controllers/ConfigurationController.cs @@ -305,8 +305,12 @@ public class ConfigurationController : ControllerBase var oldConfig = await _dataContext.QueueCleanerConfigs .FirstAsync(); - // Apply updates from DTO - newConfig.Adapt(oldConfig); + // Apply updates from DTO, excluding the ID property to avoid EF key modification error + var config = new TypeAdapterConfig(); + config.NewConfig() + .Ignore(dest => dest.Id); + + newConfig.Adapt(oldConfig, config); // Persist the configuration await _dataContext.SaveChangesAsync(); @@ -341,8 +345,12 @@ public class ConfigurationController : ControllerBase .Include(x => x.Categories) .FirstAsync(); - // Apply updates from DTO - newConfig.Adapt(oldConfig); + // Apply updates from DTO, excluding the ID property to avoid EF key modification error + var config = new TypeAdapterConfig(); + config.NewConfig() + .Ignore(dest => dest.Id); + + newConfig.Adapt(oldConfig, config); // Persist the configuration await _dataContext.SaveChangesAsync(); @@ -415,8 +423,12 @@ public class ConfigurationController : ControllerBase var oldConfig = await _dataContext.SonarrConfigs .FirstAsync(); - // Apply updates from DTO - newConfig.Adapt(oldConfig); + // Apply updates from DTO, excluding the ID property to avoid EF key modification error + var config = new TypeAdapterConfig(); + config.NewConfig() + .Ignore(dest => dest.Id); + + newConfig.Adapt(oldConfig, config); // Persist the configuration await _dataContext.SaveChangesAsync(); @@ -447,8 +459,12 @@ public class ConfigurationController : ControllerBase var oldConfig = await _dataContext.RadarrConfigs .FirstAsync(); - // Apply updates from DTO - newConfig.Adapt(oldConfig); + // Apply updates from DTO, excluding the ID property to avoid EF key modification error + var config = new TypeAdapterConfig(); + config.NewConfig() + .Ignore(dest => dest.Id); + + newConfig.Adapt(oldConfig, config); // Persist the configuration await _dataContext.SaveChangesAsync(); @@ -479,8 +495,12 @@ public class ConfigurationController : ControllerBase var oldConfig = await _dataContext.LidarrConfigs .FirstAsync(); - // Apply updates from DTO - newConfig.Adapt(oldConfig); + // Apply updates from DTO, excluding the ID property to avoid EF key modification error + var config = new TypeAdapterConfig(); + config.NewConfig() + .Ignore(dest => dest.Id); + + newConfig.Adapt(oldConfig, config); // Persist the configuration await _dataContext.SaveChangesAsync(); diff --git a/code/UI/src/app/settings/queue-cleaner/queue-cleaner-config.store.ts b/code/UI/src/app/settings/queue-cleaner/queue-cleaner-config.store.ts index 5f25d80e..6db2b0ba 100644 --- a/code/UI/src/app/settings/queue-cleaner/queue-cleaner-config.store.ts +++ b/code/UI/src/app/settings/queue-cleaner/queue-cleaner-config.store.ts @@ -54,8 +54,8 @@ export class QueueCleanerConfigStore extends signalStore( switchMap(config => configService.updateQueueCleanerConfig(config).pipe( tap({ next: () => { + // Don't set config - let the form stay as-is with string enum values patchState(store, { - config, saving: false }); },