You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs

51 lines
1.5 KiB

using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.MediaFiles
{
public interface IMediaFileRepository : IBasicRepository<MovieFile>
{
List<MovieFile> GetFilesByMovie(int movieId);
List<MovieFile> GetFilesByMovies(IEnumerable<int> movieIds);
List<MovieFile> GetFilesWithoutMediaInfo();
void DeleteForMovies(List<int> movieIds);
List<MovieFile> GetFilesWithRelativePath(int movieId, string relativePath);
}
public class MediaFileRepository : BasicRepository<MovieFile>, IMediaFileRepository
{
public MediaFileRepository(IMainDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
public List<MovieFile> GetFilesByMovie(int movieId)
{
return Query(x => x.MovieId == movieId);
}
public List<MovieFile> GetFilesByMovies(IEnumerable<int> movieIds)
{
return Query(x => movieIds.Contains(x.MovieId));
}
public List<MovieFile> GetFilesWithoutMediaInfo()
{
return Query(x => x.MediaInfo == null);
}
public void DeleteForMovies(List<int> movieIds)
{
Delete(x => movieIds.Contains(x.MovieId));
}
public List<MovieFile> GetFilesWithRelativePath(int movieId, string relativePath)
{
return Query(c => c.MovieId == movieId && c.RelativePath == relativePath);
}
}
}