mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
fixing update for vnext.
This commit is contained in:
parent
2001e5f502
commit
80c996c216
31 changed files with 279 additions and 175 deletions
49
NzbDrone.Api/Qualities/QualitySizeModule.cs
Normal file
49
NzbDrone.Api/Qualities/QualitySizeModule.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.Qualities
|
||||
{
|
||||
public class QualitySizeModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly QualitySizeService _qualityTypeProvider;
|
||||
|
||||
public QualitySizeModule(QualitySizeService qualityTypeProvider)
|
||||
: base("/qualitysizes")
|
||||
{
|
||||
_qualityTypeProvider = qualityTypeProvider;
|
||||
|
||||
Get["/"] = x => GetQualityType();
|
||||
Get["/{id}"] = x => GetQualityType(x.Id);
|
||||
Put["/"] = x => PutQualityType();
|
||||
}
|
||||
|
||||
private Response PutQualityType()
|
||||
{
|
||||
var model = Request.Body.FromJson<QualitySizeResource>();
|
||||
|
||||
var type = Mapper.Map<QualitySizeResource, QualitySize>(model);
|
||||
_qualityTypeProvider.Update(type);
|
||||
|
||||
return model.AsResponse();
|
||||
|
||||
}
|
||||
|
||||
private Response GetQualityType(int id)
|
||||
{
|
||||
var type = _qualityTypeProvider.Get(id);
|
||||
return Mapper.Map<QualitySize, QualitySizeResource>(type).AsResponse();
|
||||
}
|
||||
|
||||
private Response GetQualityType()
|
||||
{
|
||||
var types = _qualityTypeProvider.All().Where(qualityType => qualityType.QualityId != 0 && qualityType.QualityId != 10).ToList();
|
||||
var responseModel = Mapper.Map<List<QualitySize>, List<QualitySizeResource>>(types);
|
||||
|
||||
return responseModel.AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue