Lidarr/src/Lidarr.Api.V1/RemotePathMappings/RemotePathMappingResource.cs

57 lines
1.5 KiB
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using NzbDrone.Core.RemotePathMappings;
2017-09-04 02:20:56 +00:00
2017-10-31 01:28:29 +00:00
namespace Lidarr.Api.V1.RemotePathMappings
2017-09-04 02:20:56 +00:00
{
public class RemotePathMappingResource : RestResource
{
public string Host { get; set; }
public string RemotePath { get; set; }
public string LocalPath { get; set; }
}
public static class RemotePathMappingResourceMapper
{
public static RemotePathMappingResource ToResource(this RemotePathMapping model)
{
if (model == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
return new RemotePathMappingResource
{
Id = model.Id,
Host = model.Host,
RemotePath = model.RemotePath,
LocalPath = model.LocalPath
};
}
public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
{
if (resource == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
return new RemotePathMapping
{
Id = resource.Id,
Host = resource.Host,
RemotePath = resource.RemotePath,
LocalPath = resource.LocalPath
};
}
public static List<RemotePathMappingResource> ToResource(this IEnumerable<RemotePathMapping> models)
{
return models.Select(ToResource).ToList();
}
}
}