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.
recyclarr/src/Recyclarr.Cli/Pipelines/CustomFormat/PipelinePhases/CustomFormatApiPersistenceP...

30 lines
872 B

using Recyclarr.Config.Models;
using Recyclarr.ServarrApi.CustomFormat;
namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases;
public class CustomFormatApiPersistencePhase(ICustomFormatApiService 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);
}
}
}