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.
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Dynamic;
|
|
|
|
using System.Linq;
|
|
|
|
using Lidarr.Http.REST;
|
|
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
using NzbDrone.Core.CustomFilters;
|
|
|
|
|
|
|
|
namespace Lidarr.Api.V1.CustomFilters
|
|
|
|
{
|
|
|
|
public class CustomFilterResource : RestResource
|
|
|
|
{
|
|
|
|
public string Type { get; set; }
|
|
|
|
public string Label { get; set; }
|
|
|
|
public List<ExpandoObject> Filters { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class CustomFilterResourceMapper
|
|
|
|
{
|
|
|
|
public static CustomFilterResource ToResource(this CustomFilter model)
|
|
|
|
{
|
|
|
|
if (model == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new CustomFilterResource
|
|
|
|
{
|
|
|
|
Id = model.Id,
|
|
|
|
Type = model.Type,
|
|
|
|
Label = model.Label,
|
|
|
|
Filters = STJson.Deserialize<List<ExpandoObject>>(model.Filters)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CustomFilter ToModel(this CustomFilterResource resource)
|
|
|
|
{
|
|
|
|
if (resource == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new CustomFilter
|
|
|
|
{
|
|
|
|
Id = resource.Id,
|
|
|
|
Type = resource.Type,
|
|
|
|
Label = resource.Label,
|
|
|
|
Filters = STJson.ToJson(resource.Filters)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<CustomFilterResource> ToResource(this IEnumerable<CustomFilter> filters)
|
|
|
|
{
|
|
|
|
return filters.Select(ToResource).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|