1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 02:55:38 +00:00
Lidarr/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs

45 lines
1.4 KiB
C#
Raw Normal View History

2013-08-21 06:46:23 +00:00
using System.Collections.Generic;
using NzbDrone.Api.REST;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Api.Mapping;
2013-08-21 06:46:23 +00:00
namespace NzbDrone.Api.EpisodeFiles
{
public class EpisodeModule : NzbDroneRestModule<EpisodeFileResource>
{
private readonly IMediaFileService _mediaFileService;
public EpisodeModule(IMediaFileService mediaFileService)
: base("/episodefile")
{
_mediaFileService = mediaFileService;
GetResourceById = GetEpisodeFile;
GetResourceAll = GetEpisodeFiles;
2013-08-21 06:46:23 +00:00
UpdateResource = SetQuality;
}
private EpisodeFileResource GetEpisodeFile(int id)
{
return _mediaFileService.Get(id).InjectTo<EpisodeFileResource>();
}
private List<EpisodeFileResource> GetEpisodeFiles()
{
var seriesId = (int?)Request.Query.SeriesId;
if (seriesId == null)
{
throw new BadRequestException("seriesId is missing");
}
return ToListResource(() => _mediaFileService.GetFilesBySeries(seriesId.Value));
}
private void SetQuality(EpisodeFileResource episodeFileResource)
2013-08-21 06:46:23 +00:00
{
var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
episodeFile.Quality = episodeFileResource.Quality;
_mediaFileService.Update(episodeFile);
}
}
}