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