|
|
@ -1,35 +1,24 @@
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Radarr.Http.REST;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using Nancy;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using Radarr.Http;
|
|
|
|
using Radarr.Http;
|
|
|
|
|
|
|
|
using Radarr.Http.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Radarr.Api.V2.Qualities
|
|
|
|
namespace Radarr.Api.V2.Qualities
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class QualityDefinitionModule : RadarrRestModule<QualityDefinitionResource>
|
|
|
|
public class QualityDefinitionModule : RadarrRestModule<QualityDefinitionResource>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IQualityDefinitionService _qualityDefinitionService;
|
|
|
|
private readonly IQualityDefinitionService _qualityDefinitionService;
|
|
|
|
private readonly IParsingService _parsingService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public QualityDefinitionModule(IQualityDefinitionService qualityDefinitionService, IParsingService parsingService)
|
|
|
|
public QualityDefinitionModule(IQualityDefinitionService qualityDefinitionService)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_qualityDefinitionService = qualityDefinitionService;
|
|
|
|
_qualityDefinitionService = qualityDefinitionService;
|
|
|
|
_parsingService = parsingService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
|
|
|
|
|
|
|
|
GetResourceById = GetById;
|
|
|
|
GetResourceById = GetById;
|
|
|
|
|
|
|
|
|
|
|
|
UpdateResource = Update;
|
|
|
|
UpdateResource = Update;
|
|
|
|
|
|
|
|
Put("/update", d => UpdateMany());
|
|
|
|
CreateResource = Create;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int Create(QualityDefinitionResource qualityDefinitionResource)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new BadRequestException("Not allowed!");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update(QualityDefinitionResource resource)
|
|
|
|
private void Update(QualityDefinitionResource resource)
|
|
|
@ -47,5 +36,19 @@ namespace Radarr.Api.V2.Qualities
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _qualityDefinitionService.All().ToResource();
|
|
|
|
return _qualityDefinitionService.All().ToResource();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private object UpdateMany()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Read from request
|
|
|
|
|
|
|
|
var qualityDefinitions = Request.Body.FromJson<List<QualityDefinitionResource>>()
|
|
|
|
|
|
|
|
.ToModel()
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_qualityDefinitionService.UpdateMany(qualityDefinitions);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseWithCode(_qualityDefinitionService.All()
|
|
|
|
|
|
|
|
.ToResource()
|
|
|
|
|
|
|
|
, HttpStatusCode.Accepted);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|