You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1015 B
37 lines
1015 B
using Recyclarr.Cli.Pipelines.CustomFormat.Api;
|
|
using Recyclarr.TrashLib.Config.Services;
|
|
|
|
namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases;
|
|
|
|
public class CustomFormatApiPersistencePhase
|
|
{
|
|
private readonly ICustomFormatService _api;
|
|
|
|
public CustomFormatApiPersistencePhase(ICustomFormatService api)
|
|
{
|
|
_api = api;
|
|
}
|
|
|
|
public async Task Execute(IServiceConfiguration config, CustomFormatTransactionData transactions)
|
|
{
|
|
foreach (var cf in transactions.NewCustomFormats)
|
|
{
|
|
var response = await _api.CreateCustomFormat(config, cf);
|
|
if (response is not null)
|
|
{
|
|
cf.Id = response.Id;
|
|
}
|
|
}
|
|
|
|
foreach (var dto in transactions.UpdatedCustomFormats)
|
|
{
|
|
await _api.UpdateCustomFormat(config, dto);
|
|
}
|
|
|
|
foreach (var map in transactions.DeletedCustomFormats)
|
|
{
|
|
await _api.DeleteCustomFormat(config, map.CustomFormatId);
|
|
}
|
|
}
|
|
}
|