From 4504232956ac3a996667a7adcbc9e6180917b95d Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 18 Feb 2013 22:56:02 -0800 Subject: [PATCH] still very broken --- NzbDrone.Api/Series/SeriesModule.cs | 14 +- .../Datastore/SimpleRepositoryFixture.cs | 6 +- .../MonitoredEpisodeSpecificationFixture.cs | 8 +- .../JobTests/BannerDownloadJobTest.cs | 19 +-- .../JobTests/DiskScanJobTest.cs | 26 +-- .../JobTests/ImportNewSeriesJobTest.cs | 20 +-- .../JobTests/JobRepositoryFixture.cs | 38 ++--- .../JobTests/RenameSeasonJobFixture.cs | 4 +- .../CleanUpDropFolderFixture.cs | 4 +- .../MoveEpisodeFileFixture.cs | 12 +- .../DiskScanProviderTests/ScanFixture.cs | 17 +- .../ProcessDownloadFixture.cs | 30 ++-- .../ProcessDropDirectoryFixture.cs | 10 +- .../ProcessVideoFileFixture.cs | 18 +- .../SearchTests/ProcessResultsFixture.cs | 12 +- .../ProviderTests/SearchTests/TestSearch.cs | 4 +- .../RootFolderServiceFixture.cs | 2 +- .../EpisodeProviderTest.cs | 6 +- .../TvTests/SeriesProviderTest.cs | 16 +- NzbDrone.Core/Datastore/BasicRepository.cs | 8 +- .../MonitoredEpisodeSpecification.cs | 6 +- NzbDrone.Core/Jobs/BannerDownloadJob.cs | 4 +- NzbDrone.Core/Jobs/DeleteSeriesJob.cs | 2 +- NzbDrone.Core/Jobs/DiskScanJob.cs | 6 +- NzbDrone.Core/Jobs/ImportNewSeriesJob.cs | 4 +- NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs | 4 +- NzbDrone.Core/Jobs/RenameSeasonJob.cs | 7 +- NzbDrone.Core/Jobs/RenameSeriesJob.cs | 8 +- NzbDrone.Core/Jobs/UpdateInfoJob.cs | 10 +- NzbDrone.Core/NzbDrone.Core.csproj | 1 + NzbDrone.Core/Providers/DiskScanProvider.cs | 8 +- .../Providers/PostDownloadProvider.cs | 10 +- .../Providers/Search/DailyEpisodeSearch.cs | 10 +- .../Providers/Search/EpisodeSearch.cs | 4 +- .../Providers/Search/PartialSeasonSearch.cs | 4 +- NzbDrone.Core/Providers/Search/SearchBase.cs | 6 +- .../Providers/SearchHistoryProvider.cs | 6 +- NzbDrone.Core/Providers/SearchProvider.cs | 8 +- NzbDrone.Core/Providers/XemProvider.cs | 10 +- .../RootFolders/RootFolderService.cs | 10 +- NzbDrone.Core/Tv/Series.cs | 3 +- NzbDrone.Core/Tv/SeriesProvider.cs | 159 ++---------------- NzbDrone.Core/Tv/SeriesRepository.cs | 37 ++++ 43 files changed, 263 insertions(+), 338 deletions(-) create mode 100644 NzbDrone.Core/Tv/SeriesRepository.cs diff --git a/NzbDrone.Api/Series/SeriesModule.cs b/NzbDrone.Api/Series/SeriesModule.cs index 89b5da5fc..6adb1189c 100644 --- a/NzbDrone.Api/Series/SeriesModule.cs +++ b/NzbDrone.Api/Series/SeriesModule.cs @@ -16,12 +16,14 @@ namespace NzbDrone.Api.Series public class SeriesModule : NzbDroneApiModule { private readonly SeriesProvider _seriesProvider; + private readonly ISeriesRepository _seriesRepository; private readonly JobController _jobProvider; - public SeriesModule(SeriesProvider seriesProvider, JobController jobProvider) + public SeriesModule(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, JobController jobProvider) : base("/Series") { _seriesProvider = seriesProvider; + _seriesRepository = seriesRepository; _jobProvider = jobProvider; Get["/"] = x => AllSeries(); Get["/{id}"] = x => GetSeries((int)x.id); @@ -33,7 +35,7 @@ namespace NzbDrone.Api.Series private Response AllSeries() { - var series = _seriesProvider.GetAllSeriesWithEpisodeCount().ToList(); + var series = _seriesRepository.All().ToList(); var seriesModels = Mapper.Map, List>(series); return seriesModels.AsResponse(); @@ -41,7 +43,7 @@ namespace NzbDrone.Api.Series private Response GetSeries(int id) { - var series = _seriesProvider.GetSeries(id); + var series = _seriesRepository.Get(id); var seriesModels = Mapper.Map(series); return seriesModels.AsResponse(); @@ -66,7 +68,7 @@ namespace NzbDrone.Api.Series { var request = Request.Body.FromJson(); - var series = _seriesProvider.GetSeries(request.Id); + var series = _seriesRepository.Get(request.Id); series.Monitored = request.Monitored; series.SeasonFolder = request.SeasonFolder; @@ -83,12 +85,12 @@ namespace NzbDrone.Api.Series else series.CustomStartDate = null; - _seriesProvider.UpdateSeries(series); + _seriesRepository.Update(series); if (oldPath != series.Path) _jobProvider.QueueJob(typeof(DiskScanJob), new { SeriesId = series.SeriesId }); - _seriesProvider.UpdateSeries(series); + _seriesRepository.Update(series); return request.AsResponse(); } diff --git a/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs index 3e5e4de4c..384156e39 100644 --- a/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs +++ b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void should_be_able_to_add() { - Subject.Add(sampleType); + Subject.Insert(sampleType); Subject.All().Should().HaveCount(1); } @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void should_be_able_to_delete_model() { - Subject.Add(sampleType); + Subject.Insert(sampleType); Subject.All().Should().HaveCount(1); Subject.Delete(sampleType.OID); @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void should_be_able_to_find_by_id() { - Subject.Add(sampleType); + Subject.Insert(sampleType); Subject.Get(sampleType.OID) .ShouldHave() .AllProperties() diff --git a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs index f2178b001..51226ce60 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs @@ -62,8 +62,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.GetMock().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList); Mocker.GetMock().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList); - Mocker.GetMock().Setup(c => c.FindSeries(parseResultMulti.CleanTitle)).Returns(fakeSeries); - Mocker.GetMock().Setup(c => c.FindSeries(parseResultSingle.CleanTitle)).Returns(fakeSeries); + Mocker.GetMock().Setup(c => c.Get(parseResultMulti.CleanTitle)).Returns(fakeSeries); + Mocker.GetMock().Setup(c => c.Get(parseResultSingle.CleanTitle)).Returns(fakeSeries); } private void WithFirstEpisodeIgnored() @@ -95,8 +95,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void not_in_db_should_be_skipped() { - Mocker.GetMock() - .Setup(p => p.FindSeries(It.IsAny())) + Mocker.GetMock() + .Setup(p => p.Get(It.IsAny())) .Returns(null); monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse(); diff --git a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs index 333ebfee9..3fb2aae70 100644 --- a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs @@ -1,17 +1,12 @@ -using System.IO; -using System.Net; - -using FizzWare.NBuilder; +using FizzWare.NBuilder; using Moq; using NUnit.Framework; -using NzbDrone.Common; using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Core; -using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; +using System.Linq; namespace NzbDrone.Core.Test.JobTests { @@ -53,9 +48,9 @@ namespace NzbDrone.Core.Test.JobTests WithSuccessfulDownload(); var series = Builder.CreateListOfSize(5) - .Build(); + .Build().ToList(); - Mocker.GetMock().Setup(s => s.GetAllSeries()) + Mocker.GetMock().Setup(s => s.All()) .Returns(series); Mocker.Resolve().Start(_notification, null); @@ -70,9 +65,9 @@ namespace NzbDrone.Core.Test.JobTests var series = Builder.CreateListOfSize(5) .TheFirst(2) .With(s => s.BannerUrl = null) - .Build(); + .Build().ToList(); - Mocker.GetMock().Setup(s => s.GetAllSeries()) + Mocker.GetMock().Setup(s => s.All()) .Returns(series); Mocker.Resolve().Start(_notification, null); @@ -87,7 +82,7 @@ namespace NzbDrone.Core.Test.JobTests var series = Builder.CreateNew() .Build(); - Mocker.GetMock().Setup(s => s.GetSeries(series.SeriesId)) + Mocker.GetMock().Setup(s => s.Get(series.SeriesId)) .Returns(series); Mocker.Resolve().Start(_notification, new { SeriesId = series.SeriesId }); diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index eead3c6b8..ce6d40b03 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -14,6 +14,7 @@ using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; +using System.Linq; namespace NzbDrone.Core.Test.JobTests { @@ -28,9 +29,10 @@ namespace NzbDrone.Core.Test.JobTests .With(s => s.SeriesId = 12) .Build(); - Mocker.GetMock() - .Setup(p => p.GetSeries(series.SeriesId)) - .Returns(series); + + Mocker.GetMock() + .Setup(p => p.Get(series.SeriesId)); + Mocker.GetMock() .Setup(p => p.Scan(series)) @@ -51,10 +53,10 @@ namespace NzbDrone.Core.Test.JobTests var series = Builder.CreateListOfSize(2) .TheFirst(1).With(s => s.SeriesId = 12) .TheNext(1).With(s => s.SeriesId = 15) - .Build(); + .Build().ToList(); - Mocker.GetMock() - .Setup(p => p.GetAllSeries()) + Mocker.GetMock() + .Setup(p => p.All()) .Returns(series); Mocker.GetMock() @@ -77,10 +79,10 @@ namespace NzbDrone.Core.Test.JobTests var series = Builder.CreateListOfSize(2) .TheFirst(1).With(s => s.SeriesId = 12) .TheNext(1).With(s => s.SeriesId = 15) - .Build(); + .Build().ToList(); - Mocker.GetMock() - .Setup(p => p.GetAllSeries()) + Mocker.GetMock() + .Setup(p => p.All()) .Returns(series); Mocker.GetMock() @@ -104,10 +106,10 @@ namespace NzbDrone.Core.Test.JobTests var series = Builder.CreateListOfSize(2) .TheFirst(1).With(s => s.SeriesId = 12) .TheNext(1).With(s => s.SeriesId = 15) - .Build(); + .Build().ToList(); - Mocker.GetMock() - .Setup(p => p.GetAllSeries()) + Mocker.GetMock() + .Setup(p => p.All()) .Returns(series); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs index df6aea9a4..c5e8c3ce9 100644 --- a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs @@ -34,8 +34,8 @@ namespace NzbDrone.Core.Test.JobTests WithStrictMocker(); - Mocker.GetMock() - .Setup(p => p.GetAllSeries()) + Mocker.GetMock() + .Setup(p => p.All()) .Returns(series); @@ -61,11 +61,11 @@ namespace NzbDrone.Core.Test.JobTests .Setup(j => j.Start(notification, It.Is(d => d.GetPropertyValue("SeriesId") == series[1].SeriesId))) .Callback(() => series[1].LastInfoSync = DateTime.Now); - Mocker.GetMock() - .Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]); + Mocker.GetMock() + .Setup(s => s.Get(series[0].SeriesId)).Returns(series[0]); - Mocker.GetMock() - .Setup(s => s.GetSeries(series[1].SeriesId)).Returns(series[1]); + Mocker.GetMock() + .Setup(s => s.Get(series[1].SeriesId)).Returns(series[1]); Mocker.GetMock() .Setup(s => s.GetSeriesFiles(It.IsAny())).Returns(new List()); @@ -99,8 +99,8 @@ namespace NzbDrone.Core.Test.JobTests WithStrictMocker(); - Mocker.GetMock() - .Setup(p => p.GetAllSeries()) + Mocker.GetMock() + .Setup(p => p.All()) .Returns(series); Mocker.GetMock() @@ -118,8 +118,8 @@ namespace NzbDrone.Core.Test.JobTests Mocker.GetMock() .Setup(j => j.Start(notification, It.Is(d => d.GetPropertyValue("SeriesId") == series[0].SeriesId))); - Mocker.GetMock() - .Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]); + Mocker.GetMock() + .Setup(s => s.Get(series[0].SeriesId)).Returns(series[0]); Mocker.GetMock() .Setup(s => s.GetSeriesFiles(It.IsAny())).Returns(new List()); diff --git a/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs b/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs index 99c7686e4..357a66c32 100644 --- a/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs +++ b/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs @@ -41,13 +41,13 @@ namespace NzbDrone.Core.Test.JobTests Subject.Init(); Storage.All().Should().HaveCount(1); - Storage.All()[0].Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes); - Storage.All()[0].Name.Should().Be(_fakeJob.Name); - Storage.All()[0].TypeName.Should().Be(_fakeJob.GetType().ToString()); - Storage.All()[0].LastExecution.Should().HaveYear(DateTime.Now.Year); - Storage.All()[0].LastExecution.Should().HaveMonth(DateTime.Now.Month); - Storage.All()[0].LastExecution.Should().HaveDay(DateTime.Today.Day); - Storage.All()[0].Enable.Should().BeTrue(); + Storage.All().ToList()[0].Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes); + Storage.All().ToList()[0].Name.Should().Be(_fakeJob.Name); + Storage.All().ToList()[0].TypeName.Should().Be(_fakeJob.GetType().ToString()); + Storage.All().ToList()[0].LastExecution.Should().HaveYear(DateTime.Now.Year); + Storage.All().ToList()[0].LastExecution.Should().HaveMonth(DateTime.Now.Month); + Storage.All().ToList()[0].LastExecution.Should().HaveDay(DateTime.Today.Day); + Storage.All().ToList()[0].Enable.Should().BeTrue(); } [Test] @@ -108,14 +108,14 @@ namespace NzbDrone.Core.Test.JobTests .With(c => c.LastExecution = DateTime.Now.AddDays(-7).Date) .Build(); - Storage.Add(oldJob); + Storage.Insert(oldJob); var newJob = new FakeJob(); IEnumerable fakeJobs = new List { newJob }; Mocker.SetConstant(fakeJobs); - Subject.Init(); + Subject.Init(); var registeredJobs = Storage.All(); @@ -142,20 +142,20 @@ namespace NzbDrone.Core.Test.JobTests Storage.All().First().Enable.Should().BeFalse(); } -/* [Test] - public void disabled_jobs_arent_run_by_scheduler() - { - IEnumerable BaseFakeJobs = new List { disabledJob }; - Mocker.SetConstant(BaseFakeJobs); + /* [Test] + public void disabled_jobs_arent_run_by_scheduler() + { + IEnumerable BaseFakeJobs = new List { disabledJob }; + Mocker.SetConstant(BaseFakeJobs); - var jobProvider = Mocker.Resolve(); - jobProvider.QueueScheduled(); + var jobProvider = Mocker.Resolve(); + jobProvider.QueueScheduled(); - WaitForQueue(); + WaitForQueue(); - disabledJob.ExecutionCount.Should().Be(0); - }*/ + disabledJob.ExecutionCount.Should().Be(0); + }*/ } } diff --git a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs index f23dabd8d..2fafa2cce 100644 --- a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs +++ b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs @@ -36,8 +36,8 @@ namespace NzbDrone.Core.Test.JobTests .With(e => e.SeasonNumber = 5) .Build(); - Mocker.GetMock() - .Setup(s => s.GetSeries(_series.SeriesId)) + Mocker.GetMock() + .Setup(s => s.Get(_series.SeriesId)) .Returns(_series); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs index 431d1185e..2b04690bb 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests //Assert Mocker.GetMock().Verify(v => v.GetFileByPath(filename), Times.Once()); - Mocker.GetMock().Verify(v => v.GetSeries(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(v => v.Get(It.IsAny()), Times.Never()); } [Test] @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests Mocker.GetMock().Setup(s => s.GetFileByPath(filename)) .Returns(episodeFile); - Mocker.GetMock().Setup(s => s.GetSeries(It.IsAny())) + Mocker.GetMock().Setup(s => s.Get(It.IsAny())) .Returns(series); Mocker.GetMock().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId)) diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs index 3f7ac8b6a..29cac26c7 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs @@ -46,8 +46,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .With(f => f.Path = fi.FullName) .Build(); - Mocker.GetMock() - .Setup(e => e.GetSeries(fakeSeries.SeriesId)) + Mocker.GetMock() + .Setup(e => e.Get(fakeSeries.SeriesId)) .Returns(fakeSeries); Mocker.GetMock() @@ -96,8 +96,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .With(f => f.Proper = false) .Build(); - Mocker.GetMock() - .Setup(e => e.GetSeries(fakeSeries.SeriesId)) + Mocker.GetMock() + .Setup(e => e.Get(fakeSeries.SeriesId)) .Returns(fakeSeries); Mocker.GetMock() @@ -159,8 +159,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .With(f => f.Proper = false) .Build(); - Mocker.GetMock() - .Setup(e => e.GetSeries(fakeSeries.SeriesId)) + Mocker.GetMock() + .Setup(e => e.Get(fakeSeries.SeriesId)) .Returns(fakeSeries); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ScanFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ScanFixture.cs index 953b7e274..dbcfe873b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ScanFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ScanFixture.cs @@ -1,22 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using FizzWare.NBuilder; -using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Tv; -using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Core; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { @@ -27,9 +18,9 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests public void series_should_update_the_last_scan_date() { - - Mocker.GetMock() - .Setup(c => c.UpdateSeries(It.Is(s => s.LastDiskSync != null))).Verifiable(); + + Mocker.GetMock() + .Setup(c => c.Update(It.Is(s => s.LastDiskSync != null))).Verifiable(); Mocker.GetMock() .Setup(c => c.GetEpisodeBySeries(It.IsAny())) diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs index 3d38956b4..725513f84 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs @@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests private void WithValidSeries() { - Mocker.GetMock() - .Setup(c => c.FindSeries(It.IsAny())) + Mocker.GetMock() + .Setup(c => c.Get(It.IsAny())) .Returns(fakeSeries); Mocker.GetMock() @@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests droppedFolder.Create(); //Act - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null).Verifiable(); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(null).Verifiable(); Mocker.Resolve().ProcessDownload(droppedFolder); //Assert @@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\_unpack_The Office - S01E01 - Episode Title"); - Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(null).Verifiable(); + Mocker.GetMock().Setup(s => s.Get("office")).Returns(null).Verifiable(); //Act Mocker.Resolve().ProcessDownload(droppedFolder); @@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var taggedFolder = @"C:\Test\Unsorted TV\_UnknownSeries_The Office - S01E01 - Episode Title"; //Act - Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(null); + Mocker.GetMock().Setup(s => s.Get("office")).Returns(null); Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); Mocker.Resolve().ProcessDownload(droppedFolder); @@ -193,7 +193,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .Build(); //Act - Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get("office")).Returns(fakeSeries); Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List()); Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); @@ -228,7 +228,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .Build().ToList(); //Act - Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get("office")).Returns(fakeSeries); Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); @@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests WithOldWrite(); //Act - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(null); Mocker.Resolve().ProcessDownload(droppedFolder); //Assert @@ -273,7 +273,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title"; - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(null); //Act Mocker.Resolve().ProcessDownload(droppedFolder); @@ -295,7 +295,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests WithImportedFiles(droppedFolder.FullName); - Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get("office")).Returns(fakeSeries); Mocker.GetMock().Setup(s => s.CleanUpDropFolder(droppedFolder.FullName)); Mocker.GetMock().Setup(s => s.MoveEpisodeFile(It.IsAny(), true)).Returns(new EpisodeFile()); Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes()); @@ -322,7 +322,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var fakeEpisodeFiles = Builder.CreateListOfSize(2) .Build().ToList(); - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(fakeSeries); Mocker.GetMock().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true); Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); @@ -345,8 +345,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .With(s => s.Path = @"C:\Test\TV\30 Rock") .Build(); - Mocker.GetMock() - .Setup(c => c.FindSeries("rock")) + Mocker.GetMock() + .Setup(c => c.Get("rock")) .Returns(series); Mocker.GetMock() @@ -380,8 +380,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests WithImportedFiles(downloadName.FullName); - Mocker.GetMock() - .Setup(c => c.FindSeries("rock")) + Mocker.GetMock() + .Setup(c => c.Get("rock")) .Returns(fakeSeries); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs index 7d9f90175..383729efc 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs @@ -57,12 +57,12 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .Setup(c => c.GetDirectories(It.IsAny())) .Returns(subFolders); - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.SeriesPathExists(subFolders[1])) .Returns(true); - Mocker.GetMock() - .Setup(c => c.FindSeries(It.IsAny())) + Mocker.GetMock() + .Setup(c => c.Get(It.IsAny())) .Returns(fakeSeries); Mocker.GetMock() @@ -104,8 +104,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .Setup(c => c.GetVideoFiles(It.IsAny(), false)) .Returns(files); - Mocker.GetMock() - .Setup(c => c.FindSeries(It.IsAny())) + Mocker.GetMock() + .Setup(c => c.Get(It.IsAny())) .Returns(fakeSeries); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs index b16199ff7..b11a869fa 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs @@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests private void WithValidSeries() { - Mocker.GetMock() - .Setup(c => c.FindSeries(It.IsAny())) + Mocker.GetMock() + .Setup(c => c.Get(It.IsAny())) .Returns(fakeSeries); Mocker.GetMock() @@ -96,11 +96,11 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var file = Path.Combine(TempFolder, "test.avi"); //Act - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null).Verifiable(); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(null).Verifiable(); Mocker.Resolve().ProcessVideoFile(file); //Assert - Mocker.GetMock().Verify(s => s.FindSeries(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(s => s.Get(It.IsAny()), Times.Once()); ExceptionVerification.IgnoreWarns(); } @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var file = Path.Combine(TempFolder, "test.avi"); //Act - Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null); + Mocker.GetMock().Setup(s => s.Get(It.IsAny())).Returns(null); Mocker.Resolve().ProcessVideoFile(file); //Assert @@ -149,8 +149,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .With(s => s.Path = @"C:\Test\TV\30 Rock") .Build(); - Mocker.GetMock() - .Setup(c => c.FindSeries("rock")) + Mocker.GetMock() + .Setup(c => c.Get("rock")) .Returns(series); Mocker.GetMock() @@ -182,8 +182,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var downloadName = @"C:\Test\Drop\30.Rock.S01E01.Pilot.mkv"; - Mocker.GetMock() - .Setup(c => c.FindSeries("rock")) + Mocker.GetMock() + .Setup(c => c.Get("rock")) .Returns(fakeSeries); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs index 3605c4851..029f0e58b 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs @@ -58,20 +58,20 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests private void WithMatchingSeries() { - Mocker.GetMock() - .Setup(s => s.FindSeries(It.IsAny())).Returns(_matchingSeries); + Mocker.GetMock() + .Setup(s => s.Get(It.IsAny())).Returns(_matchingSeries); } private void WithMisMatchedSeries() { - Mocker.GetMock() - .Setup(s => s.FindSeries(It.IsAny())).Returns(_mismatchedSeries); + Mocker.GetMock() + .Setup(s => s.Get(It.IsAny())).Returns(_mismatchedSeries); } private void WithNullSeries() { - Mocker.GetMock() - .Setup(s => s.FindSeries(It.IsAny())).Returns(_nullSeries); + Mocker.GetMock() + .Setup(s => s.Get(It.IsAny())).Returns(_nullSeries); } private void WithSuccessfulDownload() diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs index f71725197..428dd6408 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs @@ -19,8 +19,8 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests public TestSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, - AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider) - : base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, + AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository) + : base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, allowedDownloadSpecification, searchHistoryProvider) { } diff --git a/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs b/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs index 157f8f0bb..b994b7e23 100644 --- a/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs +++ b/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.RootFolderTests Subject.Add(root); - Mocker.GetMock>().Verify(c => c.Add(root), Times.Once()); + Mocker.GetMock>().Verify(c => c.Insert(root), Times.Once()); } [Test] diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs index 42f18d3c7..487d452ed 100644 --- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs @@ -828,7 +828,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests seriesProvider.AddSeries("Test Series","c:\\test\\", tvDbSeriesId, 1, null); var episodeProvider = Mocker.Resolve(); - episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId)); + episodeProvider.RefreshEpisodeInfo(seriesProvider.ge(tvDbSeriesId)); //assert var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId); @@ -1422,7 +1422,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests Db.Insert(fakeSeries); Db.InsertMany(fakeEpisodes); - Mocker.GetMock().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get("officeus")).Returns(fakeSeries); //Act Mocker.Resolve().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus); @@ -1454,7 +1454,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests Db.Insert(fakeSeries); Db.InsertMany(fakeEpisodes); - Mocker.GetMock().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Get("officeus")).Returns(fakeSeries); //Act Mocker.Resolve().SetPostDownloadStatus(new List { 300 }, postDownloadStatus); diff --git a/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs index f30ab50fc..1945083a6 100644 --- a/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.TvTests seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId, null); //Assert - var series = seriesProvider.GetAllSeries(); + var series = seriesProvider.All(); series.Should().HaveCount(1); Assert.AreEqual(path, series.First().Path); Assert.AreEqual(tvDbId, series.First().SeriesId); @@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.TvTests //Act var seriesProvider = Mocker.Resolve(); - var series = seriesProvider.FindSeries("My Title"); + var series = seriesProvider.Get("My Title"); //Assert Assert.IsNull(series); @@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.TvTests //Act var seriesProvider = Mocker.Resolve(); - var series = seriesProvider.GetSeries(2); + var series = seriesProvider.Get(2); //Assert @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.TvTests //Act Mocker.Resolve(); - var series = Mocker.Resolve().GetSeries(1); + var series = Mocker.Resolve().Get(1); //Assert series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries); @@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.TvTests Mocker.Resolve(); Mocker.GetMock().Setup(s => s.GetSeriesId("laworder")).Returns(1); - var series = Mocker.Resolve().FindSeries("laworder"); + var series = Mocker.Resolve().Get("laworder"); //Assert series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId); @@ -180,7 +180,7 @@ namespace NzbDrone.Core.Test.TvTests var seriesProvider = Mocker.Resolve(); //Assert - seriesProvider.FindSeries("WrongTitle").Should().BeNull(); + seriesProvider.Get("WrongTitle").Should().BeNull(); } [TestCase("The Test", "Test")] @@ -204,7 +204,7 @@ namespace NzbDrone.Core.Test.TvTests Db.Insert(fakeQuality); //Act - var series = Mocker.Resolve().FindSeries(searchTitle); + var series = Mocker.Resolve().Get(searchTitle); //Assert series.Should().NotBeNull(); @@ -405,7 +405,7 @@ namespace NzbDrone.Core.Test.TvTests //Act Mocker.Resolve(); - var series = Mocker.Resolve().GetSeries(1); + var series = Mocker.Resolve().Get(1); //Assert series.QualityProfile.Should().NotBeNull(); diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs index 09cf677a9..41bf23a8b 100644 --- a/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -5,9 +5,9 @@ namespace NzbDrone.Core.Datastore { public interface IBasicRepository { - List All(); + IEnumerable All(); TModel Get(int id); - TModel Add(TModel model); + TModel Insert(TModel model); TModel Update(TModel model); TModel Upsert(TModel model); void Delete(int id); @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Datastore protected IEnumerable Queryable { get { return ObjectDatabase.AsQueryable(); } } - public List All() + public IEnumerable All() { return Queryable.ToList(); } @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Datastore return Queryable.Single(c => c.OID == id); } - public TModel Add(TModel model) + public TModel Insert(TModel model) { return ObjectDatabase.Insert(model); } diff --git a/NzbDrone.Core/DecisionEngine/MonitoredEpisodeSpecification.cs b/NzbDrone.Core/DecisionEngine/MonitoredEpisodeSpecification.cs index 5c929771f..84ad4e3fb 100644 --- a/NzbDrone.Core/DecisionEngine/MonitoredEpisodeSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/MonitoredEpisodeSpecification.cs @@ -10,12 +10,14 @@ namespace NzbDrone.Core.DecisionEngine { private readonly SeriesProvider _seriesProvider; private readonly EpisodeProvider _episodeProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider) + public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; + _seriesRepository = seriesRepository; } public MonitoredEpisodeSpecification() @@ -25,7 +27,7 @@ namespace NzbDrone.Core.DecisionEngine public virtual bool IsSatisfiedBy(EpisodeParseResult subject) { - var series = _seriesProvider.FindSeries(subject.CleanTitle); + var series = _seriesRepository.Get(subject.CleanTitle); if (series == null) { diff --git a/NzbDrone.Core/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Jobs/BannerDownloadJob.cs index be3f08213..1eacc1759 100644 --- a/NzbDrone.Core/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Jobs/BannerDownloadJob.cs @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Jobs if (options != null) { - Series series = _seriesProvider.GetSeries(options.SeriesId); + Series series = _seriesProvider.Get(options.SeriesId); if (series != null && !String.IsNullOrEmpty(series.BannerUrl)) { @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Jobs return; } - var seriesInDb = _seriesProvider.GetAllSeries(); + var seriesInDb = _seriesProvider.All(); foreach (var series in seriesInDb.Where(s => !String.IsNullOrEmpty(s.BannerUrl))) { diff --git a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs index fa8a86282..9f60dbd8c 100644 --- a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs +++ b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Jobs { Logger.Trace("Deleting Series [{0}]", seriesId); - var series = _seriesProvider.GetSeries(seriesId); + var series = _seriesProvider.Get(seriesId); var title = series.Title; notification.CurrentMessage = String.Format("Deleting '{0}' from database", title); diff --git a/NzbDrone.Core/Jobs/DiskScanJob.cs b/NzbDrone.Core/Jobs/DiskScanJob.cs index cefbb5af0..ca5a559df 100644 --- a/NzbDrone.Core/Jobs/DiskScanJob.cs +++ b/NzbDrone.Core/Jobs/DiskScanJob.cs @@ -46,14 +46,14 @@ namespace NzbDrone.Core.Jobs if (options == null || options.SeriesId == 0) { if (_configProvider.IgnoreArticlesWhenSortingSeries) - seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList(); + seriesToScan = _seriesProvider.All().OrderBy(o => o.Title.IgnoreArticles()).ToList(); else - seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList(); + seriesToScan = _seriesProvider.All().OrderBy(o => o.Title).ToList(); } else { - seriesToScan = new List() { _seriesProvider.GetSeries(options.SeriesId) }; + seriesToScan = new List() { _seriesProvider.Get(options.SeriesId) }; } foreach (var series in seriesToScan) diff --git a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs index 2aa7786fa..07bc74b71 100644 --- a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs +++ b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Jobs private void ScanSeries(ProgressNotification notification) { - var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList(); + var syncList = _seriesProvider.All().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList(); if (syncList.Count == 0) { return; @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Jobs _updateInfoJob.Start(notification, new { SeriesId = currentSeries.SeriesId }); _diskScanJob.Start(notification, new { SeriesId = currentSeries.SeriesId }); - var updatedSeries = _seriesProvider.GetSeries(currentSeries.SeriesId); + var updatedSeries = _seriesProvider.Get(currentSeries.SeriesId); AutoIgnoreSeasons(updatedSeries.SeriesId); //Download the banner for the new series diff --git a/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs b/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs index 36836360a..80bc13513 100644 --- a/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs +++ b/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs @@ -40,10 +40,10 @@ namespace NzbDrone.Core.Jobs List seriesToRefresh; if (options == null || options.SeriesId <= 0) - seriesToRefresh = _seriesProvider.GetAllSeries().ToList(); + seriesToRefresh = _seriesProvider.All().ToList(); else - seriesToRefresh = new List { _seriesProvider.GetSeries(options.SeriesId) }; + seriesToRefresh = new List { _seriesProvider.Get(options.SeriesId) }; foreach(var series in seriesToRefresh) { diff --git a/NzbDrone.Core/Jobs/RenameSeasonJob.cs b/NzbDrone.Core/Jobs/RenameSeasonJob.cs index 1b0e0da71..8d9855ab2 100644 --- a/NzbDrone.Core/Jobs/RenameSeasonJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeasonJob.cs @@ -5,7 +5,6 @@ using NLog; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; namespace NzbDrone.Core.Jobs { @@ -16,18 +15,20 @@ namespace NzbDrone.Core.Jobs private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly SeriesProvider _seriesProvider; private readonly MetadataProvider _metadataProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider, ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider, - MetadataProvider metadataProvider) + MetadataProvider metadataProvider,ISeriesRepository seriesRepository) { _mediaFileProvider = mediaFileProvider; _diskScanProvider = diskScanProvider; _externalNotificationProvider = externalNotificationProvider; _seriesProvider = seriesProvider; _metadataProvider = metadataProvider; + _seriesRepository = seriesRepository; } public string Name @@ -48,7 +49,7 @@ namespace NzbDrone.Core.Jobs if (options.SeasonNumber < 0) throw new ArgumentException("options.SeasonNumber"); - var series = _seriesProvider.GetSeries(options.SeriesId); + var series = _seriesRepository.Get(options.SeriesId); notification.CurrentMessage = String.Format("Renaming episodes for {0} Season {1}", series.Title, options.SeasonNumber); diff --git a/NzbDrone.Core/Jobs/RenameSeriesJob.cs b/NzbDrone.Core/Jobs/RenameSeriesJob.cs index d66b761bd..2df88b474 100644 --- a/NzbDrone.Core/Jobs/RenameSeriesJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeriesJob.cs @@ -16,18 +16,20 @@ namespace NzbDrone.Core.Jobs private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly SeriesProvider _seriesProvider; private readonly MetadataProvider _metadataProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider, ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider, - MetadataProvider metadataProvider) + MetadataProvider metadataProvider,ISeriesRepository seriesRepository) { _mediaFileProvider = mediaFileProvider; _diskScanProvider = diskScanProvider; _externalNotificationProvider = externalNotificationProvider; _seriesProvider = seriesProvider; _metadataProvider = metadataProvider; + _seriesRepository = seriesRepository; } public string Name @@ -46,12 +48,12 @@ namespace NzbDrone.Core.Jobs if (options == null || options.SeriesId <= 0) { - seriesToRename = _seriesProvider.GetAllSeries().ToList(); + seriesToRename = _seriesRepository.All().ToList(); } else { - seriesToRename = new List{ _seriesProvider.GetSeries(options.SeriesId) }; + seriesToRename = new List{ _seriesRepository.Get(options.SeriesId) }; } foreach(var series in seriesToRename) diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs index d84e7e446..729314506 100644 --- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs @@ -17,15 +17,17 @@ namespace NzbDrone.Core.Jobs private readonly EpisodeProvider _episodeProvider; private readonly ReferenceDataProvider _referenceDataProvider; private readonly ConfigProvider _configProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, - ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider) + ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider, ISeriesRepository seriesRepository) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; _referenceDataProvider = referenceDataProvider; _configProvider = configProvider; + _seriesRepository = seriesRepository; } public UpdateInfoJob() @@ -49,14 +51,14 @@ namespace NzbDrone.Core.Jobs if (options == null || options.SeriesId == 0) { if (_configProvider.IgnoreArticlesWhenSortingSeries) - seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList(); + seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList(); else - seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList(); + seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title).ToList(); } else { - seriesToUpdate = new List { _seriesProvider.GetSeries(options.SeriesId) }; + seriesToUpdate = new List { _seriesRepository.Get(options.SeriesId) }; } //Update any Daily Series in the DB with the IsDaily flag diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 733627dc1..d45a7444e 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -302,6 +302,7 @@ + diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index 1ddbbe203..b66c4b2fe 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -25,12 +25,13 @@ namespace NzbDrone.Core.Providers private readonly ConfigProvider _configProvider; private readonly RecycleBinProvider _recycleBinProvider; private readonly MediaInfoProvider _mediaInfoProvider; + private readonly ISeriesRepository _seriesRepository; public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider, SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider, ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider, SignalRProvider signalRProvider, ConfigProvider configProvider, - RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider) + RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider,ISeriesRepository seriesRepository) { _diskProvider = diskProvider; _episodeProvider = episodeProvider; @@ -42,6 +43,7 @@ namespace NzbDrone.Core.Providers _configProvider = configProvider; _recycleBinProvider = recycleBinProvider; _mediaInfoProvider = mediaInfoProvider; + _seriesRepository = seriesRepository; } public DiskScanProvider() @@ -97,7 +99,7 @@ namespace NzbDrone.Core.Providers //Todo: Move the episode linking to here, instead of import (or rename import) series.LastDiskSync = DateTime.Now; - _seriesProvider.UpdateSeries(series); + _seriesRepository.Update(series); return importedFiles; } @@ -190,7 +192,7 @@ namespace NzbDrone.Core.Providers if (episodeFile == null) throw new ArgumentNullException("episodeFile"); - var series = _seriesProvider.GetSeries(episodeFile.SeriesId); + var series = _seriesRepository.Get(episodeFile.SeriesId); var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId); string newFileName = _mediaFileProvider.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile); var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path)); diff --git a/NzbDrone.Core/Providers/PostDownloadProvider.cs b/NzbDrone.Core/Providers/PostDownloadProvider.cs index 6f8ae3cb0..658e2427c 100644 --- a/NzbDrone.Core/Providers/PostDownloadProvider.cs +++ b/NzbDrone.Core/Providers/PostDownloadProvider.cs @@ -18,14 +18,16 @@ namespace NzbDrone.Core.Providers private readonly DiskScanProvider _diskScanProvider; private readonly SeriesProvider _seriesProvider; private readonly MetadataProvider _metadataProvider; + private readonly ISeriesRepository _seriesRepository; public PostDownloadProvider(DiskProvider diskProvider, DiskScanProvider diskScanProvider, - SeriesProvider seriesProvider, MetadataProvider metadataProvider) + SeriesProvider seriesProvider, MetadataProvider metadataProvider,ISeriesRepository seriesRepository) { _diskProvider = diskProvider; _diskScanProvider = diskScanProvider; _seriesProvider = seriesProvider; _metadataProvider = metadataProvider; + _seriesRepository = seriesRepository; } public PostDownloadProvider() @@ -38,7 +40,7 @@ namespace NzbDrone.Core.Providers { try { - if (!_seriesProvider.SeriesPathExists(subfolder)) + if (!_seriesRepository.SeriesPathExists(subfolder)) { ProcessDownload(new DirectoryInfo(subfolder)); } @@ -77,7 +79,7 @@ namespace NzbDrone.Core.Providers } string seriesName = Parser.ParseSeriesName(RemoveStatusFromFolderName(subfolderInfo.Name)); - var series = _seriesProvider.FindSeries(seriesName); + var series = _seriesRepository.Get(seriesName); if (series == null) { @@ -147,7 +149,7 @@ namespace NzbDrone.Core.Providers } var seriesName = Parser.ParseSeriesName(Path.GetFileNameWithoutExtension(videoFile)); - var series = _seriesProvider.FindSeries(seriesName); + var series = _seriesRepository.Get(seriesName); if (series == null) { diff --git a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs index f2c736179..0c5c81c05 100644 --- a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs +++ b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs @@ -15,14 +15,16 @@ namespace NzbDrone.Core.Providers.Search { public class DailyEpisodeSearch : SearchBase { + private readonly ISeriesRepository _seriesRepository; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public DailyEpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification, - SearchHistoryProvider searchHistoryProvider) - : base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, - allowedDownloadSpecification, searchHistoryProvider) - { + SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository) + : base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, + allowedDownloadSpecification, searchHistoryProvider) + { + _seriesRepository = seriesRepository; } public DailyEpisodeSearch() diff --git a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs index 3581b22f3..2a0250fd6 100644 --- a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs +++ b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs @@ -19,8 +19,8 @@ namespace NzbDrone.Core.Providers.Search public EpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification, - SearchHistoryProvider searchHistoryProvider) - : base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, + SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository) + : base(seriesProvider,seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, allowedDownloadSpecification, searchHistoryProvider) { } diff --git a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs index 327567fb8..80f0b1bb5 100644 --- a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs +++ b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs @@ -19,8 +19,8 @@ namespace NzbDrone.Core.Providers.Search public PartialSeasonSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification, - SearchHistoryProvider searchHistoryProvider) - : base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, + SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository) + : base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider, allowedDownloadSpecification, searchHistoryProvider) { } diff --git a/NzbDrone.Core/Providers/Search/SearchBase.cs b/NzbDrone.Core/Providers/Search/SearchBase.cs index 59fc7ab33..8c2c0a823 100644 --- a/NzbDrone.Core/Providers/Search/SearchBase.cs +++ b/NzbDrone.Core/Providers/Search/SearchBase.cs @@ -16,6 +16,7 @@ namespace NzbDrone.Core.Providers.Search public abstract class SearchBase { protected readonly SeriesProvider _seriesProvider; + private readonly ISeriesRepository _seriesRepository; protected readonly EpisodeProvider _episodeProvider; protected readonly DownloadProvider _downloadProvider; protected readonly IndexerProvider _indexerProvider; @@ -25,12 +26,13 @@ namespace NzbDrone.Core.Providers.Search private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - protected SearchBase(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, + protected SearchBase(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider) { _seriesProvider = seriesProvider; + _seriesRepository = seriesRepository; _episodeProvider = episodeProvider; _downloadProvider = downloadProvider; _indexerProvider = indexerProvider; @@ -105,7 +107,7 @@ namespace NzbDrone.Core.Providers.Search items.Add(item); logger.Trace("Analysing report " + episodeParseResult); - episodeParseResult.Series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle); + episodeParseResult.Series = _seriesRepository.Get(episodeParseResult.CleanTitle); if(episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId) { diff --git a/NzbDrone.Core/Providers/SearchHistoryProvider.cs b/NzbDrone.Core/Providers/SearchHistoryProvider.cs index d7fdc816b..291204495 100644 --- a/NzbDrone.Core/Providers/SearchHistoryProvider.cs +++ b/NzbDrone.Core/Providers/SearchHistoryProvider.cs @@ -16,16 +16,18 @@ namespace NzbDrone.Core.Providers private readonly SeriesProvider _seriesProvider; private readonly DownloadProvider _downloadProvider; private readonly EpisodeProvider _episodeProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider, - DownloadProvider downloadProvider, EpisodeProvider episodeProvider) + DownloadProvider downloadProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository) { _database = database; _seriesProvider = seriesProvider; _downloadProvider = downloadProvider; _episodeProvider = episodeProvider; + _seriesRepository = seriesRepository; } public SearchHistoryProvider() @@ -105,7 +107,7 @@ namespace NzbDrone.Core.Providers var item = _database.Single(itemId); logger.Info("Starting Force Download of: {0}", item.ReportTitle); var searchResult = _database.Single(item.SearchHistoryId); - var series = _seriesProvider.GetSeries(searchResult.SeriesId); + var series = _seriesRepository.Get(searchResult.SeriesId); var parseResult = Parser.ParseTitle(item.ReportTitle); parseResult.NzbUrl = item.NzbUrl; diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index a1256db7e..eae5f9125 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -19,15 +19,17 @@ namespace NzbDrone.Core.Providers private readonly SeriesProvider _seriesProvider; private readonly EpisodeProvider _episodeProvider; private readonly PartialSeasonSearch _partialSeasonSearch; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public SearchProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, - PartialSeasonSearch partialSeasonSearch) + PartialSeasonSearch partialSeasonSearch,ISeriesRepository seriesRepository) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; _partialSeasonSearch = partialSeasonSearch; + _seriesRepository = seriesRepository; } public SearchProvider() @@ -36,7 +38,7 @@ namespace NzbDrone.Core.Providers public virtual List SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber) { - var series = _seriesProvider.GetSeries(seriesId); + var series = _seriesRepository.Get(seriesId); if (series == null) { @@ -65,7 +67,7 @@ namespace NzbDrone.Core.Providers public virtual List PartialSeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber) { - var series = _seriesProvider.GetSeries(seriesId); + var series = _seriesRepository.Get(seriesId); if (series == null) { diff --git a/NzbDrone.Core/Providers/XemProvider.cs b/NzbDrone.Core/Providers/XemProvider.cs index 0f5489134..1c1bac1aa 100644 --- a/NzbDrone.Core/Providers/XemProvider.cs +++ b/NzbDrone.Core/Providers/XemProvider.cs @@ -13,15 +13,17 @@ namespace NzbDrone.Core.Providers private readonly SeriesProvider _seriesProvider; private readonly EpisodeProvider _episodeProvider; private readonly XemCommunicationProvider _xemCommunicationProvider; + private readonly ISeriesRepository _seriesRepository; private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); public XemProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, - XemCommunicationProvider xemCommunicationProvider) + XemCommunicationProvider xemCommunicationProvider,ISeriesRepository seriesRepository) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; _xemCommunicationProvider = xemCommunicationProvider; + _seriesRepository = seriesRepository; } public XemProvider() @@ -34,7 +36,7 @@ namespace NzbDrone.Core.Providers try { var ids = _xemCommunicationProvider.GetXemSeriesIds(); - var series = _seriesProvider.GetAllSeries(); + var series = _seriesRepository.All(); var wantedSeries = series.Where(s => ids.Contains(s.SeriesId)).ToList(); foreach(var ser in wantedSeries) @@ -62,7 +64,7 @@ namespace NzbDrone.Core.Providers return; } - var series = _seriesProvider.GetSeries(seriesId); + var series = _seriesRepository.Get(seriesId); if (series == null) { @@ -112,7 +114,7 @@ namespace NzbDrone.Core.Providers _logger.Trace("Setting UseSceneMapping for {0}", series.Title); series.UseSceneNumbering = true; - _seriesProvider.UpdateSeries(series); + _seriesRepository.Update(series); } catch (Exception ex) diff --git a/NzbDrone.Core/RootFolders/RootFolderService.cs b/NzbDrone.Core/RootFolders/RootFolderService.cs index 3fc33386d..1121c0d88 100644 --- a/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -24,18 +24,20 @@ namespace NzbDrone.Core.RootFolders private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IBasicRepository _rootFolderRepository; private readonly DiskProvider _diskProvider; + private readonly ISeriesRepository _seriesRepository; private readonly SeriesProvider _seriesProvider; - public RootFolderService(IBasicRepository rootFolderRepository, SeriesProvider seriesProvider, DiskProvider diskProvider) + public RootFolderService(IBasicRepository rootFolderRepository, SeriesProvider seriesProvider, DiskProvider diskProvider,ISeriesRepository seriesRepository) { _rootFolderRepository = rootFolderRepository; _diskProvider = diskProvider; + _seriesRepository = seriesRepository; _seriesProvider = seriesProvider; } public virtual List All() { - var rootFolders = _rootFolderRepository.All(); + var rootFolders = _rootFolderRepository.All().ToList(); rootFolders.ForEach(folder => { @@ -60,7 +62,7 @@ namespace NzbDrone.Core.RootFolders if (All().Exists(r => DiskProvider.PathEquals(r.Path, rootFolder.Path))) throw new InvalidOperationException("Root directory already exist."); - _rootFolderRepository.Add(rootFolder); + _rootFolderRepository.Insert(rootFolder); rootFolder.FreeSpace = _diskProvider.FreeDiskSpace(rootFolder.Path); rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path); @@ -88,7 +90,7 @@ namespace NzbDrone.Core.RootFolders foreach (string seriesFolder in _diskProvider.GetDirectories(path)) { - if (!_seriesProvider.SeriesPathExists(seriesFolder)) + if (!_seriesRepository.SeriesPathExists(seriesFolder)) { var di = new DirectoryInfo(seriesFolder.Normalize()); results.Add(new UnmappedFolder{ Name = di.Name, Path = di.FullName }); diff --git a/NzbDrone.Core/Tv/Series.cs b/NzbDrone.Core/Tv/Series.cs index 74783ec9a..e7110b2d8 100644 --- a/NzbDrone.Core/Tv/Series.cs +++ b/NzbDrone.Core/Tv/Series.cs @@ -1,11 +1,12 @@ using System.Linq; using System; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Model; using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Core.Tv { - public class Series + public class Series : ModelBase { public virtual int SeriesId { get; set; } diff --git a/NzbDrone.Core/Tv/SeriesProvider.cs b/NzbDrone.Core/Tv/SeriesProvider.cs index 0a2873b94..6a2d7cf69 100644 --- a/NzbDrone.Core/Tv/SeriesProvider.cs +++ b/NzbDrone.Core/Tv/SeriesProvider.cs @@ -15,10 +15,9 @@ namespace NzbDrone.Core.Tv { public class SeriesProvider { - + private readonly ISeriesRepository _seriesRepository; private readonly ConfigProvider _configProvider; private readonly TvDbProvider _tvDbProvider; - private readonly IDatabase _database; private readonly SceneMappingProvider _sceneNameMappingProvider; private readonly BannerProvider _bannerProvider; private readonly MetadataProvider _metadataProvider; @@ -28,12 +27,12 @@ namespace NzbDrone.Core.Tv private static readonly Regex TimeRegex = new Regex(@"^(?