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

48 lines
1.3 KiB
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using NzbDrone.Core.Download;
using NzbDrone.Core.Indexers;
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
{
public bool Enable { get; set; }
public DownloadProtocol Protocol { get; set; }
public int Priority { 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;
2017-09-04 02:20:56 +00:00
return resource;
}
public override DownloadClientDefinition ToModel(DownloadClientResource resource)
{
if (resource == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
var definition = base.ToModel(resource);
definition.Enable = resource.Enable;
definition.Protocol = resource.Protocol;
definition.Priority = resource.Priority;
2017-09-04 02:20:56 +00:00
return definition;
}
}
}