mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.MediaFiles
|
|
{
|
|
public interface IMediaFileRepository : IBasicRepository<EpisodeFile>
|
|
{
|
|
EpisodeFile GetFileByPath(string path);
|
|
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
|
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
|
}
|
|
|
|
|
|
public class MediaFileRepository : BasicRepository<EpisodeFile>, IMediaFileRepository
|
|
{
|
|
public MediaFileRepository(IDatabase database)
|
|
: base(database)
|
|
{
|
|
}
|
|
|
|
|
|
public EpisodeFile GetFileByPath(string path)
|
|
{
|
|
return Query.SingleOrDefault(c => c.Path == path);
|
|
}
|
|
|
|
public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
|
{
|
|
return Query.Where(c => c.SeriesId == seriesId).ToList();
|
|
}
|
|
|
|
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
|
{
|
|
return Query.Where(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber).ToList();
|
|
|
|
}
|
|
}
|
|
} |