From 17c8b8803b0d3ab5d12cc2b128f636921795b6cd Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 25 Apr 2011 17:28:33 -0700 Subject: [PATCH] removed some unneeded injection dependencies. renamed dependency fields to be standard across the app. --- .../Providers/Core/ConfigProvider.cs | 16 +++--- NzbDrone.Core/Providers/EpisodeProvider.cs | 46 +++++++--------- NzbDrone.Core/Providers/HistoryProvider.cs | 16 +++--- NzbDrone.Core/Providers/MediaFileProvider.cs | 1 + NzbDrone.Core/Providers/QualityProvider.cs | 18 +++---- NzbDrone.Core/Providers/RenameProvider.cs | 5 +- NzbDrone.Core/Providers/SabProvider.cs | 34 ++++++------ NzbDrone.Core/Providers/SeasonProvider.cs | 24 ++++----- NzbDrone.Core/Providers/SeriesProvider.cs | 54 +++++++++---------- .../Providers/UpcomingEpisodesProvider.cs | 14 ++--- 10 files changed, 111 insertions(+), 117 deletions(-) diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index a026123e9..4761db871 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -10,16 +10,16 @@ namespace NzbDrone.Core.Providers.Core public class ConfigProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _sonicRepo; + private readonly IRepository _repository; - public ConfigProvider(IRepository dataRepository) + public ConfigProvider(IRepository repository) { - _sonicRepo = dataRepository; + _repository = repository; } public IList All() { - return _sonicRepo.All().ToList(); + return _repository.All().ToList(); } public ConfigProvider() @@ -220,7 +220,7 @@ namespace NzbDrone.Core.Providers.Core { string value; - var dbValue = _sonicRepo.Single(key); + var dbValue = _repository.Single(key); if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) return dbValue.Value; @@ -252,11 +252,11 @@ namespace NzbDrone.Core.Providers.Core Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value); - var dbValue = _sonicRepo.Single(key); + var dbValue = _repository.Single(key); if (dbValue == null) { - _sonicRepo.Add(new Config + _repository.Add(new Config { Key = key, Value = value @@ -265,7 +265,7 @@ namespace NzbDrone.Core.Providers.Core else { dbValue.Value = value; - _sonicRepo.Update(dbValue); + _repository.Update(dbValue); } } } diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 4d5202c0f..4eefb176e 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -12,21 +12,15 @@ namespace NzbDrone.Core.Providers public class EpisodeProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly QualityProvider _qualityProvider; - private readonly SeasonProvider _seasons; - private readonly SeriesProvider _series; - private readonly IRepository _sonicRepo; - private readonly TvDbProvider _tvDb; + private readonly SeasonProvider _seasonsProvider; + private readonly IRepository _repository; + private readonly TvDbProvider _tvDbProvider; - public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider, - SeasonProvider seasonProvider, TvDbProvider tvDbProvider, - QualityProvider qualityProvider) + public EpisodeProvider(IRepository repository, SeasonProvider seasonProviderProvider, TvDbProvider tvDbProviderProvider) { - _sonicRepo = sonicRepo; - _series = seriesProvider; - _tvDb = tvDbProvider; - _seasons = seasonProvider; - _qualityProvider = qualityProvider; + _repository = repository; + _tvDbProvider = tvDbProviderProvider; + _seasonsProvider = seasonProviderProvider; } public EpisodeProvider() @@ -35,36 +29,36 @@ namespace NzbDrone.Core.Providers public virtual Episode GetEpisode(long id) { - return _sonicRepo.Single(id); + return _repository.Single(id); } public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber) { return - _sonicRepo.Single( + _repository.Single( c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber); } public virtual Episode GetEpisode(int seriesId, DateTime date) { return - _sonicRepo.Single( + _repository.Single( c => c.SeriesId == seriesId && c.AirDate == date.Date); } public virtual IList GetEpisodeBySeries(long seriesId) { - return _sonicRepo.Find(e => e.SeriesId == seriesId); + return _repository.Find(e => e.SeriesId == seriesId); } public virtual IList GetEpisodeBySeason(long seasonId) { - return _sonicRepo.Find(e => e.SeasonId == seasonId); + return _repository.Find(e => e.SeasonId == seasonId); } public virtual IList GetEpisodeByParseResult(EpisodeParseResult parseResult) { - var seasonEpisodes = _sonicRepo.All().Where(e => + var seasonEpisodes = _repository.All().Where(e => e.SeriesId == parseResult.SeriesId && e.SeasonNumber == parseResult.SeasonNumber).ToList(); @@ -102,7 +96,7 @@ namespace NzbDrone.Core.Providers Language = "en" }; - _sonicRepo.Add(episodeInfo); + _repository.Add(episodeInfo); } @@ -151,7 +145,7 @@ namespace NzbDrone.Core.Providers Logger.Info("Starting episode info refresh for series:{0}", seriesId); int successCount = 0; int failCount = 0; - var targetSeries = _tvDb.GetSeries(seriesId, true); + var targetSeries = _tvDbProvider.GetSeries(seriesId, true); var updateList = new List(); var newList = new List(); @@ -159,7 +153,7 @@ namespace NzbDrone.Core.Providers Logger.Debug("Updating season info for series:{0}", targetSeries.SeriesName); targetSeries.Episodes.Select(e => new { e.SeasonId, e.SeasonNumber }) .Distinct().ToList() - .ForEach(s => _seasons.EnsureSeason(seriesId, s.SeasonId, s.SeasonNumber)); + .ForEach(s => _seasonsProvider.EnsureSeason(seriesId, s.SeasonId, s.SeasonNumber)); foreach (var episode in targetSeries.Episodes) { @@ -214,8 +208,8 @@ namespace NzbDrone.Core.Providers } } - _sonicRepo.AddMany(newList); - _sonicRepo.UpdateMany(updateList); + _repository.AddMany(newList); + _repository.UpdateMany(updateList); Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount); @@ -223,12 +217,12 @@ namespace NzbDrone.Core.Providers public virtual void DeleteEpisode(int episodeId) { - _sonicRepo.Delete(episodeId); + _repository.Delete(episodeId); } public virtual void UpdateEpisode(Episode episode) { - _sonicRepo.Update(episode); + _repository.Update(episode); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 5b473a754..354f3b366 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -11,11 +11,11 @@ namespace NzbDrone.Core.Providers public class HistoryProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _sonicRepo; + private readonly IRepository _repository; - public HistoryProvider(IRepository sonicRepo) + public HistoryProvider(IRepository repository) { - _sonicRepo = sonicRepo; + _repository = repository; } public HistoryProvider() @@ -24,32 +24,32 @@ namespace NzbDrone.Core.Providers public virtual IQueryable AllItems() { - return _sonicRepo.All(); + return _repository.All(); } public virtual void Purge() { - _sonicRepo.DeleteMany(AllItems()); + _repository.DeleteMany(AllItems()); Logger.Info("History has been Purged"); } public virtual void Trim() { var old = AllItems().Where(h => h.Date < DateTime.Now.AddDays(-30)); - _sonicRepo.DeleteMany(old); + _repository.DeleteMany(old); Logger.Info("History has been trimmed, items older than 30 days have been removed"); } public virtual void Add(History item) { - _sonicRepo.Add(item); + _repository.Add(item); Logger.Debug("Item added to history: {0}", item.NzbTitle); } public virtual bool Exists(int episodeId, QualityTypes quality, bool proper) { //Looks for the existence of this episode in History - if (_sonicRepo.Exists(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper)) + if (_repository.Exists(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper)) return true; Logger.Debug("Episode not in History. ID:{0} Q:{1} Proper:{2}", episodeId, quality, proper); diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index fabf65837..ae0069951 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -159,6 +159,7 @@ namespace NzbDrone.Core.Providers /// list of files to verify public void CleanUp(List files) { + //TODO: remove orphaned files. in files table but not linked to from episode table. foreach (var episodeFile in files) { if (!_diskProvider.FileExists(episodeFile.Path)) diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index 8be07272e..939c3832c 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -10,48 +10,48 @@ namespace NzbDrone.Core.Providers public class QualityProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _sonicRepo; + private readonly IRepository _repository; public QualityProvider() { } - public QualityProvider(IRepository sonicRepo) + public QualityProvider(IRepository repository) { - _sonicRepo = sonicRepo; + _repository = repository; } public virtual int Add(QualityProfile profile) { - return Convert.ToInt32(_sonicRepo.Add(profile)); + return Convert.ToInt32(_repository.Add(profile)); } public virtual void Update(QualityProfile profile) { - if (!_sonicRepo.Exists(q => q.QualityProfileId == profile.QualityProfileId)) + if (!_repository.Exists(q => q.QualityProfileId == profile.QualityProfileId)) { Logger.Error("Unable to update non-existing profile"); throw new InvalidOperationException("Unable to update non-existing profile"); } - _sonicRepo.Update(profile); + _repository.Update(profile); } public virtual void Delete(int profileId) { - _sonicRepo.Delete(profileId); + _repository.Delete(profileId); } public virtual List GetAllProfiles() { - var profiles = _sonicRepo.All().ToList(); + var profiles = _repository.All().ToList(); return profiles; } public virtual QualityProfile Find(int profileId) { - return _sonicRepo.Single(q => q.QualityProfileId == profileId); + return _repository.Single(q => q.QualityProfileId == profileId); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/RenameProvider.cs b/NzbDrone.Core/Providers/RenameProvider.cs index e139f1fbc..35c4572c5 100644 --- a/NzbDrone.Core/Providers/RenameProvider.cs +++ b/NzbDrone.Core/Providers/RenameProvider.cs @@ -12,16 +12,19 @@ namespace NzbDrone.Core.Providers { public class RenameProvider { + //TODO: Remove some of these dependencies. we shouldn't have a single class with dependency on the whole app! + //TODO: Also upgrade to a job that can run on background thread. private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly ConfigProvider _configProvider; private readonly DiskProvider _diskProvider; private readonly EpisodeProvider _episodeProvider; - private readonly List _epsToRename = new List(); private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly MediaFileProvider _mediaFileProvider; private readonly SeasonProvider _seasonProvider; private readonly SeriesProvider _seriesProvider; + private readonly List _epsToRename = new List(); + private Thread _renameThread; public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index ed0aef3a2..8fdc3175c 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -13,25 +13,25 @@ namespace NzbDrone.Core.Providers public class SabProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly ConfigProvider _config; - private readonly HttpProvider _http; + private readonly ConfigProvider _configProvider; + private readonly HttpProvider _httpProvider; public SabProvider() { } - public SabProvider(ConfigProvider config, HttpProvider http) + public SabProvider(ConfigProvider configProvider, HttpProvider httpProvider) { - _config = config; - _http = http; + _configProvider = configProvider; + _httpProvider = httpProvider; } public virtual bool AddByUrl(string url, string title) { const string mode = "addurl"; - string cat = _config.GetValue("SabTvCategory", String.Empty, true); + string cat = _configProvider.GetValue("SabTvCategory", String.Empty, true); //string cat = "tv"; - string priority = _config.GetValue("SabTvPriority", String.Empty, false); + string priority = _configProvider.GetValue("SabTvPriority", String.Empty, false); string name = url.Replace("&", "%26"); string nzbName = HttpUtility.UrlEncode(title); @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Providers Logger.Debug("Adding report [{0}] to the queue.", nzbName); - string response = _http.DownloadString(request).Replace("\n", String.Empty); + string response = _httpProvider.DownloadString(request).Replace("\n", String.Empty); Logger.Debug("Queue Repsonse: [{0}]", response); if (response == "ok") @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Providers { const string action = "mode=queue&output=xml"; string request = GetSabRequest(action); - string response = _http.DownloadString(request); + string response = _httpProvider.DownloadString(request); XDocument xDoc = XDocument.Parse(response); @@ -84,9 +84,9 @@ namespace NzbDrone.Core.Providers //mode=addid&name=333333&pp=3&script=customscript.cmd&cat=Example&priority=-1 const string mode = "addid"; - string cat = _config.GetValue("SabTvCategory", String.Empty, true); + string cat = _configProvider.GetValue("SabTvCategory", String.Empty, true); //string cat = "tv"; - string priority = _config.GetValue("SabTvPriority", String.Empty, false); + string priority = _configProvider.GetValue("SabTvPriority", String.Empty, false); string nzbName = HttpUtility.UrlEncode(title); string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat, @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Providers Logger.Debug("Adding report [{0}] to the queue.", nzbName); - string response = _http.DownloadString(request).Replace("\n", String.Empty); + string response = _httpProvider.DownloadString(request).Replace("\n", String.Empty); Logger.Debug("Queue Repsonse: [{0}]", response); if (response == "ok") @@ -106,11 +106,11 @@ namespace NzbDrone.Core.Providers private string GetSabRequest(string action) { - string sabnzbdInfo = _config.GetValue("SabHost", String.Empty, false) + ":" + - _config.GetValue("SabPort", String.Empty, false); - string username = _config.GetValue("SabUsername", String.Empty, false); - string password = _config.GetValue("SabPassword", String.Empty, false); - string apiKey = _config.GetValue("SabApiKey", String.Empty, false); + string sabnzbdInfo = _configProvider.GetValue("SabHost", String.Empty, false) + ":" + + _configProvider.GetValue("SabPort", String.Empty, false); + string username = _configProvider.GetValue("SabUsername", String.Empty, false); + string password = _configProvider.GetValue("SabPassword", String.Empty, false); + string apiKey = _configProvider.GetValue("SabApiKey", String.Empty, false); return string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, diff --git a/NzbDrone.Core/Providers/SeasonProvider.cs b/NzbDrone.Core/Providers/SeasonProvider.cs index b128ea46e..101f37870 100644 --- a/NzbDrone.Core/Providers/SeasonProvider.cs +++ b/NzbDrone.Core/Providers/SeasonProvider.cs @@ -10,11 +10,11 @@ namespace NzbDrone.Core.Providers public class SeasonProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _sonicRepo; + private readonly IRepository _repository; - public SeasonProvider(IRepository dataRepository) + public SeasonProvider(IRepository repository) { - _sonicRepo = dataRepository; + _repository = repository; } public SeasonProvider() @@ -23,27 +23,27 @@ namespace NzbDrone.Core.Providers public virtual Season GetSeason(int seasonId) { - return _sonicRepo.Single(seasonId); + return _repository.Single(seasonId); } public virtual Season GetSeason(int seriesId, int seasonNumber) { - return _sonicRepo.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); + return _repository.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); } public virtual List GetSeasons(int seriesId) { - return _sonicRepo.All().Where(s => s.SeriesId == seriesId).ToList(); + return _repository.All().Where(s => s.SeriesId == seriesId).ToList(); } public virtual Season GetLatestSeason(int seriesId) { - return _sonicRepo.All().Where(s => s.SeriesId == seriesId).OrderBy(s => s.SeasonNumber).Last(); + return _repository.All().Where(s => s.SeriesId == seriesId).OrderBy(s => s.SeasonNumber).Last(); } public virtual void EnsureSeason(int seriesId, int seasonId, int seasonNumber) { - if (_sonicRepo.Exists(s => s.SeasonId == seasonId)) + if (_repository.Exists(s => s.SeasonId == seasonId)) return; //TODO: Calculate Season Folder Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId, @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Providers SeasonNumber = seasonNumber, SeriesId = seriesId }; - _sonicRepo.Add(newSeason); + _repository.Add(newSeason); } public virtual int SaveSeason(Season season) @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Providers public virtual bool IsIgnored(int seasonId) { - if (_sonicRepo.Single(seasonId).Monitored) + if (_repository.Single(seasonId).Monitored) return false; Logger.Debug("Season {0} is not wanted."); @@ -75,13 +75,13 @@ namespace NzbDrone.Core.Providers public virtual bool IsIgnored(int seriesId, int seasonNumber) { - var season = _sonicRepo.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); + var season = _repository.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); return !season.Monitored; } public void DeleteSeason(int seasonId) { - _sonicRepo.Delete(seasonId); + _repository.Delete(seasonId); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 0c47ec76f..6bdee1408 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -13,22 +13,18 @@ namespace NzbDrone.Core.Providers public class SeriesProvider { //TODO: Remove parsing of rest of tv show info we just need the show name - //Trims all white spaces and separators from the end of the title. private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly ConfigProvider _config; - private readonly QualityProvider _quality; - private readonly IRepository _sonioRepo; - private readonly TvDbProvider _tvDb; + private readonly IRepository _repository; + private readonly ConfigProvider _configProvider; + private readonly TvDbProvider _tvDbProvider; - public SeriesProvider(ConfigProvider configProvider, - IRepository dataRepository, TvDbProvider tvDbProvider, QualityProvider quality) + public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository, TvDbProvider tvDbProviderProvider) { - _config = configProvider; - _sonioRepo = dataRepository; - _tvDb = tvDbProvider; - _quality = quality; + _configProvider = configProviderProvider; + _repository = repository; + _tvDbProvider = tvDbProviderProvider; } public SeriesProvider() @@ -37,12 +33,12 @@ namespace NzbDrone.Core.Providers public virtual IQueryable GetAllSeries() { - return _sonioRepo.All(); + return _repository.All(); } public virtual Series GetSeries(int seriesId) { - return _sonioRepo.Single(s => s.SeriesId == seriesId); + return _repository.Single(s => s.SeriesId == seriesId); } /// @@ -52,12 +48,12 @@ namespace NzbDrone.Core.Providers /// Whether or not the show is monitored public virtual bool IsMonitored(long id) { - return _sonioRepo.Exists(c => c.SeriesId == id && c.Monitored); + return _repository.Exists(c => c.SeriesId == id && c.Monitored); } public virtual bool QualityWanted(int seriesId, QualityTypes quality) { - var series = _sonioRepo.Single(seriesId); + var series = _repository.Single(seriesId); Logger.Trace("Series {0} is using quality profile {1}", seriesId, series.QualityProfile.Name); return series.QualityProfile.Allowed.Contains(quality); } @@ -65,17 +61,17 @@ namespace NzbDrone.Core.Providers public virtual TvdbSeries MapPathToSeries(string path) { var seriesPath = new DirectoryInfo(path); - var searchResults = _tvDb.GetSeries(seriesPath.Name); + var searchResults = _tvDbProvider.GetSeries(seriesPath.Name); if (searchResults == null) return null; - return _tvDb.GetSeries(searchResults.Id, false); + return _tvDbProvider.GetSeries(searchResults.Id, false); } public virtual Series UpdateSeriesInfo(int seriesId) { - var tvDbSeries = _tvDb.GetSeries(seriesId, true); + var tvDbSeries = _tvDbProvider.GetSeries(seriesId, true); var series = GetSeries(seriesId); series.SeriesId = tvDbSeries.Id; @@ -102,22 +98,22 @@ namespace NzbDrone.Core.Providers repoSeries.Monitored = true; //New shows should be monitored repoSeries.QualityProfileId = qualityProfileId; if (qualityProfileId == 0) - repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true)); + repoSeries.QualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true)); - repoSeries.SeasonFolder = _config.UseSeasonFolder; + repoSeries.SeasonFolder = _configProvider.UseSeasonFolder; - _sonioRepo.Add(repoSeries); + _repository.Add(repoSeries); } public virtual Series FindSeries(string title) { var normalizeTitle = Parser.NormalizeTitle(title); - return _sonioRepo.Single(s => s.CleanTitle == normalizeTitle); + return _repository.Single(s => s.CleanTitle == normalizeTitle); } public virtual void UpdateSeries(Series series) { - _sonioRepo.Update(series); + _repository.Update(series); } public virtual void DeleteSeries(int seriesId) @@ -126,22 +122,22 @@ namespace NzbDrone.Core.Providers try { - var series = _sonioRepo.Single(seriesId); + var series = _repository.Single(seriesId); //Delete Files, Episdes, Seasons then the Series //Can't use providers because episode provider needs series provider - Cyclic Dependency Injection, this will work Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.SeriesId); - _sonioRepo.DeleteMany(series.EpisodeFiles); + _repository.DeleteMany(series.EpisodeFiles); Logger.Debug("Deleting Episodes from DB for Series: {0}", series.SeriesId); - _sonioRepo.DeleteMany(series.Episodes); + _repository.DeleteMany(series.Episodes); Logger.Debug("Deleting Seasons from DB for Series: {0}", series.SeriesId); - _sonioRepo.DeleteMany(series.Seasons); + _repository.DeleteMany(series.Seasons); Logger.Debug("Deleting Series from DB {0}", series.Title); - _sonioRepo.Delete(seriesId); + _repository.Delete(seriesId); Logger.Info("Successfully deleted Series [{0}]", seriesId); } @@ -154,7 +150,7 @@ namespace NzbDrone.Core.Providers public virtual bool SeriesPathExists(string cleanPath) { - if (_sonioRepo.Exists(s => s.Path == cleanPath)) + if (_repository.Exists(s => s.Path == cleanPath)) return true; return false; diff --git a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs index 8707c94c6..50611fa45 100644 --- a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs +++ b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs @@ -9,17 +9,17 @@ namespace NzbDrone.Core.Providers { public class UpcomingEpisodesProvider { - private readonly IRepository _sonicRepo; + private readonly IRepository _repository; - public UpcomingEpisodesProvider(IRepository sonicRepo) + public UpcomingEpisodesProvider(IRepository repository) { - _sonicRepo = sonicRepo; + _repository = repository; } public virtual UpcomingEpisodesModel Upcoming() { var allEps = - _sonicRepo.All().Where( + _repository.All().Where( e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8)); var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); @@ -31,18 +31,18 @@ namespace NzbDrone.Core.Providers public virtual List Yesterday() { - return _sonicRepo.All().Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); + return _repository.All().Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); } public virtual List Today() { - return _sonicRepo.All().Where(e => e.AirDate == DateTime.Today).ToList(); + return _repository.All().Where(e => e.AirDate == DateTime.Today).ToList(); } public virtual List Week() { return - _sonicRepo.All().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)) + _repository.All().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)) .ToList(); } }