2013-03-01 10:03:41 +03:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-09-11 09:33:47 +03:00
|
|
|
using NzbDrone.Core.Messaging;
|
|
|
|
|
2013-03-01 10:03:41 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.MediaFiles
|
|
|
|
{
|
|
|
|
public interface IMediaFileRepository : IBasicRepository<EpisodeFile>
|
|
|
|
{
|
|
|
|
EpisodeFile GetFileByPath(string path);
|
|
|
|
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
2013-07-19 08:23:04 +03:00
|
|
|
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
2013-06-02 22:29:00 +03:00
|
|
|
bool Exists(string path);
|
2013-03-01 10:03:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MediaFileRepository : BasicRepository<EpisodeFile>, IMediaFileRepository
|
|
|
|
{
|
2013-05-06 00:24:33 +03:00
|
|
|
public MediaFileRepository(IDatabase database, IMessageAggregator messageAggregator)
|
|
|
|
: base(database, messageAggregator)
|
2013-03-01 10:03:41 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public EpisodeFile GetFileByPath(string path)
|
|
|
|
{
|
2013-03-27 06:44:52 +03:00
|
|
|
return Query.SingleOrDefault(c => c.Path == path);
|
2013-03-01 10:03:41 +03:00
|
|
|
}
|
|
|
|
|
2013-07-19 08:23:04 +03:00
|
|
|
public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
2013-06-02 22:29:00 +03:00
|
|
|
{
|
2013-07-19 08:23:04 +03:00
|
|
|
return Query.Where(c => c.SeriesId == seriesId).ToList();
|
2013-06-02 22:29:00 +03:00
|
|
|
}
|
|
|
|
|
2013-07-19 08:23:04 +03:00
|
|
|
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
2013-03-01 10:03:41 +03:00
|
|
|
{
|
2013-07-19 08:23:04 +03:00
|
|
|
return Query.Where(c => c.SeriesId == seriesId)
|
|
|
|
.AndWhere(c => c.SeasonNumber == seasonNumber)
|
|
|
|
.ToList();
|
2013-03-01 10:03:41 +03:00
|
|
|
}
|
|
|
|
|
2013-07-19 08:23:04 +03:00
|
|
|
public bool Exists(string path)
|
|
|
|
{
|
|
|
|
return Query.Any(c => c.Path == path);
|
|
|
|
}
|
2013-03-01 10:03:41 +03:00
|
|
|
}
|
|
|
|
}
|