Fixed Episode to EpisodeFile relationship (So getting the EpisodeFIle gets associated Episode(s) as well.

This commit is contained in:
markus101 2011-02-23 16:40:11 -08:00
parent 568a9d1d24
commit e7cabfe235
5 changed files with 15 additions and 6 deletions

View File

@ -21,7 +21,9 @@ namespace NzbDrone.Core.Providers
private readonly IQualityProvider _quality; private readonly IQualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public EpisodeProvider(IRepository sonicRepo, ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, ITvDbProvider tvDbProvider, IHistoryProvider history, IQualityProvider quality) public EpisodeProvider(IRepository sonicRepo, ISeriesProvider seriesProvider,
ISeasonProvider seasonProvider, ITvDbProvider tvDbProvider,
IHistoryProvider history, IQualityProvider quality)
{ {
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
_series = seriesProvider; _series = seriesProvider;
@ -94,7 +96,7 @@ namespace NzbDrone.Core.Providers
episode.EpisodeId = dbEpisode.EpisodeId; episode.EpisodeId = dbEpisode.EpisodeId;
var file = _sonicRepo.Single<EpisodeFile>(c => c.FileId == dbEpisode.FileId); var file = dbEpisode.EpisodeFile;
if (file != null) if (file != null)
{ {

View File

@ -1,3 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -17,5 +18,6 @@ namespace NzbDrone.Core.Providers
void DeleteFromDisk(int fileId, string path); void DeleteFromDisk(int fileId, string path);
void Update(EpisodeFile episodeFile); void Update(EpisodeFile episodeFile);
EpisodeFile GetEpisodeFile(int episodeFileId); EpisodeFile GetEpisodeFile(int episodeFileId);
List<EpisodeFile> GetEpisodeFiles();
} }
} }

View File

@ -85,11 +85,11 @@ namespace NzbDrone.Core.Providers
string episodeList = String.Empty; string episodeList = String.Empty;
foreach (var ep in episodes) foreach (var ep in episodes)
{ {
ep.FileId = fileId; ep.EpisodeFileId = fileId;
_episodeProvider.UpdateEpisode(ep); _episodeProvider.UpdateEpisode(ep);
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ','); episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
} }
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.FileId, filePath, episodeList); Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.EpisodeFileId, filePath, episodeList);
return episodeFile; return episodeFile;
} }
@ -148,6 +148,11 @@ namespace NzbDrone.Core.Providers
return _repository.Single<EpisodeFile>(episodeFileId); return _repository.Single<EpisodeFile>(episodeFileId);
} }
public List<EpisodeFile> GetEpisodeFiles()
{
return _repository.All<EpisodeFile>().ToList();
}
private List<string> GetMediaFileList(string path) private List<string> GetMediaFileList(string path)
{ {
Logger.Debug("Scanning '{0}' for episodes", path); Logger.Debug("Scanning '{0}' for episodes", path);

View File

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Repository
[SubSonicPrimaryKey(false)] [SubSonicPrimaryKey(false)]
public virtual int EpisodeId { get; set; } public virtual int EpisodeId { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }
public virtual int FileId { get; set; } public virtual int EpisodeFileId { get; set; }
public int SeasonNumber { get; set; } public int SeasonNumber { get; set; }
public int EpisodeNumber { get; set; } public int EpisodeNumber { get; set; }
public int SeasonId { get; set; } public int SeasonId { get; set; }

View File

@ -8,7 +8,7 @@ namespace NzbDrone.Core.Repository
public class EpisodeFile public class EpisodeFile
{ {
[SubSonicPrimaryKey] [SubSonicPrimaryKey]
public virtual int FileId { get; set; } public virtual int EpisodeFileId { get; set; }
public int SeriesId { get; set; } public int SeriesId { get; set; }
public string Path { get; set; } public string Path { get; set; }
public QualityTypes Quality { get; set; } public QualityTypes Quality { get; set; }