mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-17 02:07:50 -05:00
try fix sonarr
This commit is contained in:
@@ -228,9 +228,10 @@ public class ConfigurationController : ControllerBase
|
||||
try
|
||||
{
|
||||
var config = await _dataContext.ArrConfigs
|
||||
.Include(x => x.Instances)
|
||||
.AsNoTracking()
|
||||
.FirstAsync(x => x.Type == InstanceType.Sonarr);
|
||||
return Ok(config);
|
||||
return Ok(config.Adapt<ArrConfigDto>());
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -577,7 +578,6 @@ public class ConfigurationController : ControllerBase
|
||||
{
|
||||
// Get the Sonarr config to add the instance to
|
||||
var config = await _dataContext.ArrConfigs
|
||||
.Include(c => c.Instances)
|
||||
.FirstAsync(x => x.Type == InstanceType.Sonarr);
|
||||
|
||||
// Create the new instance
|
||||
@@ -585,14 +585,17 @@ public class ConfigurationController : ControllerBase
|
||||
{
|
||||
Name = newInstance.Name,
|
||||
Url = new Uri(newInstance.Url),
|
||||
ApiKey = newInstance.ApiKey
|
||||
ApiKey = newInstance.ApiKey,
|
||||
ArrConfigId = config.Id,
|
||||
};
|
||||
|
||||
// Add to the config
|
||||
config.Instances.Add(instance);
|
||||
// Add to the config's instances collection
|
||||
// config.Instances.Add(instance);
|
||||
await _dataContext.ArrInstances.AddAsync(instance);
|
||||
// Save changes
|
||||
await _dataContext.SaveChangesAsync();
|
||||
|
||||
return CreatedAtAction(nameof(GetSonarrConfig), new { id = instance.Id }, instance);
|
||||
return CreatedAtAction(nameof(GetSonarrConfig), new { id = instance.Id }, instance.Adapt<ArrInstanceDto>());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -629,7 +632,7 @@ public class ConfigurationController : ControllerBase
|
||||
|
||||
await _dataContext.SaveChangesAsync();
|
||||
|
||||
return Ok(instance);
|
||||
return Ok(instance.Adapt<ArrInstanceDto>());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -692,7 +695,9 @@ public class ConfigurationController : ControllerBase
|
||||
{
|
||||
Name = newInstance.Name,
|
||||
Url = new Uri(newInstance.Url),
|
||||
ApiKey = newInstance.ApiKey
|
||||
ApiKey = newInstance.ApiKey,
|
||||
ArrConfigId = config.Id,
|
||||
ArrConfig = config // Set the navigation property
|
||||
};
|
||||
|
||||
// Add to the config
|
||||
@@ -799,7 +804,9 @@ public class ConfigurationController : ControllerBase
|
||||
{
|
||||
Name = newInstance.Name,
|
||||
Url = new Uri(newInstance.Url),
|
||||
ApiKey = newInstance.ApiKey
|
||||
ApiKey = newInstance.ApiKey,
|
||||
ArrConfigId = config.Id,
|
||||
ArrConfig = config // Set the navigation property
|
||||
};
|
||||
|
||||
// Add to the config
|
||||
|
||||
16
code/Executable/DTOs/ArrConfigDto.cs
Normal file
16
code/Executable/DTOs/ArrConfigDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Data.Enums;
|
||||
|
||||
namespace Executable.DTOs;
|
||||
|
||||
public class ArrConfigDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required InstanceType Type { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public short FailedImportMaxStrikes { get; set; } = -1;
|
||||
|
||||
public List<ArrInstanceDto> Instances { get; set; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user