2013-01-19 02:27:30 +01:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-05-31 02:12:20 +02:00
|
|
|
|
using NzbDrone.Api.Mapping;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-05-20 02:30:02 +02:00
|
|
|
|
namespace NzbDrone.Api.Qualities
|
2013-01-19 02:27:30 +01:00
|
|
|
|
{
|
2013-05-31 02:12:20 +02:00
|
|
|
|
public class QualitySizeModule : NzbDroneRestModule<QualitySizeResource>
|
2013-01-19 02:27:30 +01:00
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
private readonly QualitySizeService _qualityTypeProvider;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-03-07 09:01:18 +01:00
|
|
|
|
public QualitySizeModule(QualitySizeService qualityTypeProvider)
|
2013-01-19 02:27:30 +01:00
|
|
|
|
{
|
2013-01-20 01:19:27 +01:00
|
|
|
|
_qualityTypeProvider = qualityTypeProvider;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
GetResourceAll = GetAll;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
GetResourceById = GetById;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
UpdateResource = Update;
|
2013-01-19 02:27:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
private QualitySizeResource Update(QualitySizeResource resource)
|
2013-01-19 02:27:30 +01:00
|
|
|
|
{
|
2013-05-31 02:12:20 +02:00
|
|
|
|
var model = resource.InjectTo<QualitySize>();
|
|
|
|
|
_qualityTypeProvider.Update(model);
|
|
|
|
|
return GetById(resource.Id);
|
2013-01-19 02:27:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
private QualitySizeResource GetById(int id)
|
2013-01-19 02:27:30 +01:00
|
|
|
|
{
|
2013-05-31 02:12:20 +02:00
|
|
|
|
return ToResource(() => _qualityTypeProvider.Get(id));
|
|
|
|
|
}
|
2013-01-19 02:27:30 +01:00
|
|
|
|
|
2013-05-31 02:12:20 +02:00
|
|
|
|
private List<QualitySizeResource> GetAll()
|
|
|
|
|
{
|
|
|
|
|
return ToListResource(_qualityTypeProvider.All);
|
2013-01-19 02:27:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|