Lidarr/src/Lidarr.Api.V1/DownloadClient/DownloadClientResource.cs

53 lines
1.8 KiB
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using NzbDrone.Core.Download;
2017-10-31 01:28:29 +00:00
namespace Lidarr.Api.V1.DownloadClient
2017-09-04 02:20:56 +00:00
{
public class DownloadClientResource : ProviderResource<DownloadClientResource>
2017-09-04 02:20:56 +00:00
{
public bool Enable { get; set; }
2022-07-19 20:08:53 +00:00
public string Protocol { get; set; }
public int Priority { get; set; }
public bool RemoveCompletedDownloads { get; set; }
public bool RemoveFailedDownloads { get; set; }
2017-09-04 02:20:56 +00:00
}
public class DownloadClientResourceMapper : ProviderResourceMapper<DownloadClientResource, DownloadClientDefinition>
{
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
{
if (definition == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
var resource = base.ToResource(definition);
resource.Enable = definition.Enable;
resource.Protocol = definition.Protocol;
resource.Priority = definition.Priority;
resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads;
resource.RemoveFailedDownloads = definition.RemoveFailedDownloads;
2017-09-04 02:20:56 +00:00
return resource;
}
public override DownloadClientDefinition ToModel(DownloadClientResource resource, DownloadClientDefinition existingDefinition)
2017-09-04 02:20:56 +00:00
{
if (resource == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
var definition = base.ToModel(resource, existingDefinition);
2017-09-04 02:20:56 +00:00
definition.Enable = resource.Enable;
definition.Protocol = resource.Protocol;
definition.Priority = resource.Priority;
definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads;
definition.RemoveFailedDownloads = resource.RemoveFailedDownloads;
2017-09-04 02:20:56 +00:00
return definition;
}
}
}