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