2013-07-19 03:47:55 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-06-25 07:21:10 +00:00
|
|
|
|
using System.Linq;
|
2014-06-08 08:22:55 +00:00
|
|
|
|
using NzbDrone.Api.Mapping;
|
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
|
using NzbDrone.Core.Profiles;
|
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-06-25 07:21:10 +00:00
|
|
|
|
|
2014-06-08 08:22:55 +00:00
|
|
|
|
namespace NzbDrone.Api.Profiles
|
2013-06-25 07:21:10 +00:00
|
|
|
|
{
|
2014-06-08 08:22:55 +00:00
|
|
|
|
public class ProfileSchemaModule : NzbDroneRestModule<ProfileResource>
|
2013-06-25 07:21:10 +00:00
|
|
|
|
{
|
2014-01-18 11:44:36 +00:00
|
|
|
|
private readonly IQualityDefinitionService _qualityDefinitionService;
|
|
|
|
|
|
2014-06-08 08:22:55 +00:00
|
|
|
|
public ProfileSchemaModule(IQualityDefinitionService qualityDefinitionService)
|
|
|
|
|
: base("/profile/schema")
|
2013-06-25 07:21:10 +00:00
|
|
|
|
{
|
2014-01-18 11:44:36 +00:00
|
|
|
|
_qualityDefinitionService = qualityDefinitionService;
|
|
|
|
|
|
2013-06-25 07:21:10 +00:00
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-08 08:22:55 +00:00
|
|
|
|
private List<ProfileResource> GetAll()
|
2013-06-25 07:21:10 +00:00
|
|
|
|
{
|
2014-01-29 00:53:59 +00:00
|
|
|
|
var items = _qualityDefinitionService.All()
|
|
|
|
|
.OrderBy(v => v.Weight)
|
2014-06-08 08:22:55 +00:00
|
|
|
|
.Select(v => new ProfileQualityItem { Quality = v.Quality, Allowed = false })
|
2014-01-29 00:53:59 +00:00
|
|
|
|
.ToList();
|
|
|
|
|
|
2014-06-08 08:22:55 +00:00
|
|
|
|
var profile = new Profile();
|
2013-06-25 07:21:10 +00:00
|
|
|
|
profile.Cutoff = Quality.Unknown;
|
2014-01-29 00:53:59 +00:00
|
|
|
|
profile.Items = items;
|
2014-06-08 08:22:55 +00:00
|
|
|
|
profile.Language = Language.English;
|
2014-01-18 11:44:36 +00:00
|
|
|
|
|
2014-06-08 08:22:55 +00:00
|
|
|
|
return new List<ProfileResource> { profile.InjectTo<ProfileResource>() };
|
2013-06-25 07:21:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|