1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 08:22:35 +01:00
Sonarr/NzbDrone.Core/MediaFiles/MediaFileRepository.cs

40 lines
1.0 KiB
C#
Raw Normal View History

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