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.
65 lines
1.6 KiB
65 lines
1.6 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NzbDrone.Core.Restrictions;
|
|
using Radarr.Http.REST;
|
|
|
|
namespace Radarr.Http.RESTrictions
|
|
{
|
|
public class RestrictionResource : RestResource
|
|
{
|
|
public string Required { get; set; }
|
|
public string Preferred { get; set; }
|
|
public string Ignored { get; set; }
|
|
public HashSet<int> Tags { get; set; }
|
|
|
|
public RestrictionResource()
|
|
{
|
|
Tags = new HashSet<int>();
|
|
}
|
|
}
|
|
|
|
public static class RestrictionResourceMapper
|
|
{
|
|
public static RestrictionResource ToResource(this Restriction model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new RestrictionResource
|
|
{
|
|
Id = model.Id,
|
|
|
|
Required = model.Required,
|
|
Preferred = model.Preferred,
|
|
Ignored = model.Ignored,
|
|
Tags = new HashSet<int>(model.Tags)
|
|
};
|
|
}
|
|
|
|
public static Restriction ToModel(this RestrictionResource resource)
|
|
{
|
|
if (resource == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Restriction
|
|
{
|
|
Id = resource.Id,
|
|
|
|
Required = resource.Required,
|
|
Preferred = resource.Preferred,
|
|
Ignored = resource.Ignored,
|
|
Tags = new HashSet<int>(resource.Tags)
|
|
};
|
|
}
|
|
|
|
public static List<RestrictionResource> ToResource(this IEnumerable<Restriction> models)
|
|
{
|
|
return models.Select(ToResource).ToList();
|
|
}
|
|
}
|
|
}
|