|
|
|
@ -11,11 +11,11 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
|
|
|
|
[V1ApiController]
|
|
|
|
|
public class QualityProfileController : RestController<QualityProfileResource>
|
|
|
|
|
{
|
|
|
|
|
private readonly IProfileService _profileService;
|
|
|
|
|
private readonly IQualityProfileService _qualityProfileService;
|
|
|
|
|
|
|
|
|
|
public QualityProfileController(IProfileService profileService)
|
|
|
|
|
public QualityProfileController(IQualityProfileService qualityProfileService)
|
|
|
|
|
{
|
|
|
|
|
_profileService = profileService;
|
|
|
|
|
_qualityProfileService = qualityProfileService;
|
|
|
|
|
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
|
|
|
|
SharedValidator.RuleFor(c => c.Cutoff).ValidCutoff();
|
|
|
|
|
SharedValidator.RuleFor(c => c.Items).ValidItems();
|
|
|
|
@ -25,14 +25,14 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
|
|
|
|
public ActionResult<QualityProfileResource> Create(QualityProfileResource resource)
|
|
|
|
|
{
|
|
|
|
|
var model = resource.ToModel();
|
|
|
|
|
model = _profileService.Add(model);
|
|
|
|
|
model = _qualityProfileService.Add(model);
|
|
|
|
|
return Created(model.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[RestDeleteById]
|
|
|
|
|
public void DeleteProfile(int id)
|
|
|
|
|
{
|
|
|
|
|
_profileService.Delete(id);
|
|
|
|
|
_qualityProfileService.Delete(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[RestPutById]
|
|
|
|
@ -40,20 +40,20 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
|
|
|
|
{
|
|
|
|
|
var model = resource.ToModel();
|
|
|
|
|
|
|
|
|
|
_profileService.Update(model);
|
|
|
|
|
_qualityProfileService.Update(model);
|
|
|
|
|
|
|
|
|
|
return Accepted(model.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override QualityProfileResource GetResourceById(int id)
|
|
|
|
|
{
|
|
|
|
|
return _profileService.Get(id).ToResource();
|
|
|
|
|
return _qualityProfileService.Get(id).ToResource();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<QualityProfileResource> GetAll()
|
|
|
|
|
{
|
|
|
|
|
return _profileService.All().ToResource();
|
|
|
|
|
return _qualityProfileService.All().ToResource();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|