2013-03-01 08:03:41 +01:00
|
|
|
using System.Collections.Generic;
|
2013-03-24 05:16:00 +01:00
|
|
|
using System.Data;
|
2013-03-01 08:03:41 +01:00
|
|
|
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
|
|
|
|
{
|
2013-03-24 05:16:00 +01:00
|
|
|
public MediaFileRepository(IDbConnection database)
|
|
|
|
: base(database)
|
2013-03-01 08:03:41 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public EpisodeFile GetFileByPath(string path)
|
|
|
|
{
|
2013-03-24 05:16:00 +01:00
|
|
|
return SingleOrDefault(c => c.Path == path);
|
2013-03-01 08:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
|
|
|
{
|
2013-03-24 05:16:00 +01:00
|
|
|
return Where(c => c.SeriesId == seriesId).ToList();
|
2013-03-01 08:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-03-24 05:16:00 +01:00
|
|
|
return Where(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber).ToList();
|
2013-03-01 08:03:41 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|