Renamed all Core.Controllers to Core.Providers to avoid confusion between Core Controllers and MVC controllers
This commit is contained in:
parent
9515c8788a
commit
01c1943d0e
|
@ -6,7 +6,7 @@ using log4net;
|
|||
using MbUnit.Framework;
|
||||
using MbUnit.Framework.ContractVerifiers;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using SubSonic.Repository;
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test
|
|||
var repo = new Mock<IRepository>();
|
||||
var config = new Config { Key = key, Value = value };
|
||||
repo.Setup(r => r.Single<Config>(key)).Returns(config);
|
||||
var target = new DbConfigController(new Mock<ILog>().Object, repo.Object);
|
||||
var target = new ConfigProvider(new Mock<ILog>().Object, repo.Object);
|
||||
|
||||
//Act
|
||||
target.SetValue(key, value);
|
||||
|
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test
|
|||
//Arrange
|
||||
var repo = new Mock<IRepository>();
|
||||
repo.Setup(r => r.Single<Config>(It.IsAny<string>())).Returns<Config>(null).Verifiable();
|
||||
var target = new DbConfigController(new Mock<ILog>().Object, repo.Object);
|
||||
var target = new ConfigProvider(new Mock<ILog>().Object, repo.Object);
|
||||
|
||||
//Act
|
||||
target.SetValue(key, value);
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
|
@ -18,21 +18,21 @@ namespace NzbDrone.Core.Test
|
|||
}
|
||||
|
||||
|
||||
public static IConfigController StandardConfig
|
||||
public static IConfigProvider StandardConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
var mock = new Mock<IConfigController>();
|
||||
var mock = new Mock<IConfigProvider>();
|
||||
mock.SetupGet(c => c.SeriesRoot).Returns("C:\\");
|
||||
return mock.Object;
|
||||
}
|
||||
}
|
||||
|
||||
public static IDiskController StandardDisk
|
||||
public static IDiskProvider StandardDisk
|
||||
{
|
||||
get
|
||||
{
|
||||
var mock = new Mock<IDiskController>();
|
||||
var mock = new Mock<IDiskProvider>();
|
||||
mock.Setup(c => c.GetDirectories(It.IsAny<String>())).Returns(StandardSeries);
|
||||
mock.Setup(c => c.Exists(It.Is<String>(d => StandardSeries.Contains(d)))).Returns(true);
|
||||
return mock.Object;
|
||||
|
|
|
@ -7,8 +7,8 @@ using log4net;
|
|||
using MbUnit.Framework;
|
||||
using MbUnit.Framework.ContractVerifiers;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using SubSonic.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
|
@ -26,17 +26,17 @@ namespace NzbDrone.Core.Test
|
|||
string password = "pass";
|
||||
string priority = "0";
|
||||
|
||||
var config = new Mock<IConfigController>();
|
||||
var config = new Mock<IConfigProvider>();
|
||||
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
|
||||
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
|
||||
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
|
||||
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
|
||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||
|
||||
var http = new Mock<IHttpController>();
|
||||
var http = new Mock<IHttpProvider>();
|
||||
http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("ok");
|
||||
|
||||
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
|
||||
ItemInfo nzb = new ItemInfo();
|
||||
nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232");
|
||||
|
@ -59,17 +59,17 @@ namespace NzbDrone.Core.Test
|
|||
string password = "pass";
|
||||
string priority = "0";
|
||||
|
||||
var config = new Mock<IConfigController>();
|
||||
var config = new Mock<IConfigProvider>();
|
||||
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
|
||||
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
|
||||
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
|
||||
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
|
||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||
|
||||
var http = new Mock<IHttpController>();
|
||||
var http = new Mock<IHttpProvider>();
|
||||
http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("error");
|
||||
|
||||
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
|
||||
ItemInfo nzb = new ItemInfo();
|
||||
nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232");
|
||||
|
@ -92,21 +92,21 @@ namespace NzbDrone.Core.Test
|
|||
string password = "pass";
|
||||
string priority = "0";
|
||||
|
||||
var config = new Mock<IConfigController>();
|
||||
var config = new Mock<IConfigProvider>();
|
||||
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
|
||||
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
|
||||
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
|
||||
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
|
||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||
|
||||
var http = new Mock<IHttpController>();
|
||||
var http = new Mock<IHttpProvider>();
|
||||
http.Setup(
|
||||
s =>
|
||||
s.GetRequest(
|
||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd());
|
||||
|
||||
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
|
||||
Episode episode = new Episode();
|
||||
FeedItem item = new FeedItem();
|
||||
|
@ -130,21 +130,21 @@ namespace NzbDrone.Core.Test
|
|||
string password = "pass";
|
||||
string priority = "0";
|
||||
|
||||
var config = new Mock<IConfigController>();
|
||||
var config = new Mock<IConfigProvider>();
|
||||
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
|
||||
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
|
||||
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
|
||||
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
|
||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||
|
||||
var http = new Mock<IHttpController>();
|
||||
var http = new Mock<IHttpProvider>();
|
||||
http.Setup(
|
||||
s =>
|
||||
s.GetRequest(
|
||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd());
|
||||
|
||||
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
|
||||
Episode episode = new Episode();
|
||||
FeedItem item = new FeedItem();
|
||||
|
@ -168,21 +168,21 @@ namespace NzbDrone.Core.Test
|
|||
string password = "pass";
|
||||
string priority = "0";
|
||||
|
||||
var config = new Mock<IConfigController>();
|
||||
var config = new Mock<IConfigProvider>();
|
||||
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
|
||||
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
|
||||
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
|
||||
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
|
||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||
|
||||
var http = new Mock<IHttpController>();
|
||||
var http = new Mock<IHttpProvider>();
|
||||
http.Setup(
|
||||
s =>
|
||||
s.GetRequest(
|
||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd());
|
||||
|
||||
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||
|
||||
Episode episode = new Episode();
|
||||
FeedItem item = new FeedItem();
|
||||
|
|
|
@ -10,7 +10,7 @@ using MbUnit.Framework.ContractVerifiers;
|
|||
using Moq;
|
||||
using Ninject;
|
||||
using Ninject.Moq;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using SubSonic.Repository;
|
||||
using TvdbLib.Data;
|
||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Arrange
|
||||
var moqData = new Mock<IRepository>();
|
||||
var moqTvdb = new Mock<ITvDbController>();
|
||||
var moqTvdb = new Mock<ITvDbProvider>();
|
||||
|
||||
//setup db to return a fake series
|
||||
Series fakeSeries = Builder<Series>.CreateNew()
|
||||
|
@ -52,14 +52,14 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
var kernel = new MockingKernel();
|
||||
kernel.Bind<IRepository>().ToConstant(moqData.Object);
|
||||
kernel.Bind<ITvDbController>().ToConstant(moqTvdb.Object);
|
||||
kernel.Bind<IConfigController>().ToConstant(MockLib.StandardConfig);
|
||||
kernel.Bind<IDiskController>().ToConstant(MockLib.StandardDisk);
|
||||
kernel.Bind<ISeriesController>().To<SeriesController>();
|
||||
kernel.Bind<ITvDbProvider>().ToConstant(moqTvdb.Object);
|
||||
kernel.Bind<IConfigProvider>().ToConstant(MockLib.StandardConfig);
|
||||
kernel.Bind<IDiskProvider>().ToConstant(MockLib.StandardDisk);
|
||||
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
||||
|
||||
|
||||
//Act
|
||||
var seriesController = kernel.Get<ISeriesController>();
|
||||
var seriesController = kernel.Get<ISeriesProvider>();
|
||||
seriesController.SyncSeriesWithDisk();
|
||||
|
||||
//Assert
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Text;
|
|||
using Gallio.Framework;
|
||||
using MbUnit.Framework;
|
||||
using MbUnit.Framework.ContractVerifiers;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test
|
|||
[Ignore("Have to find a way to mock app path for tests.")]
|
||||
public void TestSearch(string title)
|
||||
{
|
||||
var tvCont =new TvDbController();
|
||||
var tvCont =new TvDbProvider();
|
||||
var result = tvCont.SearchSeries(title);
|
||||
|
||||
Assert.AreNotEqual(0, result.Count);
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
{
|
||||
public interface IConfigController
|
||||
{
|
||||
String SeriesRoot
|
||||
{
|
||||
get;
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
string GetValue(string key, object defaultValue, bool makePermanent);
|
||||
void SetValue(string key, string value);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
{
|
||||
public interface IHttpController
|
||||
{
|
||||
string GetRequest(string request);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
using System.Web;
|
||||
using log4net;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using SubSonic.DataProviders;
|
||||
using SubSonic.Repository;
|
||||
|
||||
|
@ -17,10 +17,10 @@ namespace NzbDrone.Core
|
|||
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
|
||||
var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
|
||||
kernel.Bind<ISeriesController>().To<SeriesController>();
|
||||
kernel.Bind<IDiskController>().To<DiskController>();
|
||||
kernel.Bind<ITvDbController>().To<TvDbController>();
|
||||
kernel.Bind<IConfigController>().To<DbConfigController>();
|
||||
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
||||
kernel.Bind<IDiskProvider>().To<DiskProvider>();
|
||||
kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
|
||||
kernel.Bind<IConfigProvider>().To<ConfigProvider>();
|
||||
kernel.Bind<ILog>().ToMethod(c => LogManager.GetLogger("logger-name"));
|
||||
kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations));
|
||||
}
|
||||
|
|
|
@ -135,13 +135,13 @@
|
|||
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\DbConfigController.cs" />
|
||||
<Compile Include="Controllers\HttpController.cs" />
|
||||
<Compile Include="Controllers\IDownloadClientController.cs" />
|
||||
<Compile Include="Controllers\IHttpController.cs" />
|
||||
<Compile Include="Controllers\ISeriesController.cs" />
|
||||
<Compile Include="Controllers\ITvDbController.cs" />
|
||||
<Compile Include="Controllers\SabController.cs" />
|
||||
<Compile Include="Providers\ConfigProvider.cs" />
|
||||
<Compile Include="Providers\HttpProvider.cs" />
|
||||
<Compile Include="Providers\IDownloadProvider.cs" />
|
||||
<Compile Include="Providers\IHttpProvider.cs" />
|
||||
<Compile Include="Providers\ISeriesProvider.cs" />
|
||||
<Compile Include="Providers\ITvDbProvider.cs" />
|
||||
<Compile Include="Providers\SabProvider.cs" />
|
||||
<Compile Include="Helpers\Disk.cs" />
|
||||
<Compile Include="Repository\Config.cs" />
|
||||
<Compile Include="Repository\Episode.cs" />
|
||||
|
@ -151,11 +151,11 @@
|
|||
<Compile Include="Repository\Series.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Controllers\DiskController.cs" />
|
||||
<Compile Include="Controllers\IConfigController.cs" />
|
||||
<Compile Include="Controllers\IDiskController.cs" />
|
||||
<Compile Include="Controllers\SeriesController.cs" />
|
||||
<Compile Include="Controllers\TvDbController.cs" />
|
||||
<Compile Include="Providers\DiskProvider.cs" />
|
||||
<Compile Include="Providers\IConfigProvider.cs" />
|
||||
<Compile Include="Providers\IDiskProvider.cs" />
|
||||
<Compile Include="Providers\SeriesProvider.cs" />
|
||||
<Compile Include="Providers\TvDbProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
|
@ -202,6 +202,7 @@
|
|||
<Content Include="Libraries\TvdbLib.pdb" />
|
||||
<Content Include="Libraries\TvdbLib.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using log4net;
|
||||
using NzbDrone.Core.Repository;
|
||||
using SubSonic.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class DbConfigController : IConfigController
|
||||
public class ConfigProvider : IConfigProvider
|
||||
{
|
||||
private const string _seriesroots = "SeriesRoots";
|
||||
private const string SERIES_ROOTS = "SeriesRoots";
|
||||
private readonly ILog _logger;
|
||||
private readonly IRepository _sonicRepo;
|
||||
|
||||
|
||||
public DbConfigController(ILog logger, IRepository dataRepository)
|
||||
public ConfigProvider(ILog logger, IRepository dataRepository)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
|
@ -31,12 +29,12 @@ namespace NzbDrone.Core.Controllers
|
|||
{
|
||||
get
|
||||
{
|
||||
return GetValue(_seriesroots);
|
||||
return GetValue(SERIES_ROOTS);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(_seriesroots, value);
|
||||
SetValue(SERIES_ROOTS, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class DiskController : IDiskController
|
||||
public class DiskProvider : IDiskProvider
|
||||
{
|
||||
#region IDiskController Members
|
||||
#region IDiskProvider Members
|
||||
|
||||
public bool Exists(string path)
|
||||
{
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
class HttpController : IHttpController
|
||||
class HttpProvider : IHttpProvider
|
||||
{
|
||||
public string GetRequest(string request)
|
||||
{
|
||||
//Get the request and return as String Array
|
||||
|
||||
try
|
||||
{
|
||||
var webClient = new WebClient();
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface IConfigProvider
|
||||
{
|
||||
String SeriesRoot { get; set; }
|
||||
|
||||
string GetValue(string key, object defaultValue, bool makePermanent);
|
||||
void SetValue(string key, string value);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface IDiskController
|
||||
public interface IDiskProvider
|
||||
{
|
||||
bool Exists(string path);
|
||||
string[] GetDirectories(string path);
|
|
@ -1,12 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface IDownloadClientController
|
||||
public interface IDownloadProvider
|
||||
{
|
||||
bool AddByUrl(ItemInfo nzb); //Should accept something other than string (NzbInfo?) returns success or failure
|
||||
bool IsInQueue(Episode episode);//Should accept something other than string (Episode?) returns bool
|
|
@ -0,0 +1,7 @@
|
|||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface IHttpProvider
|
||||
{
|
||||
string GetRequest(string request);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
using System.Linq;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface ISeriesController
|
||||
public interface ISeriesProvider
|
||||
{
|
||||
IQueryable<Series> GetSeries();
|
||||
Series GetSeries(int tvdbId);
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface ITvDbController
|
||||
public interface ITvDbProvider
|
||||
{
|
||||
IList<TvdbSearchResult> SearchSeries(string name);
|
||||
TvdbSeries GetSeries(int id, TvdbLanguage language);
|
|
@ -1,31 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using log4net;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SabController : IDownloadClientController
|
||||
public class SabProvider : IDownloadProvider
|
||||
{
|
||||
private readonly IConfigController _config;
|
||||
private readonly IConfigProvider _config;
|
||||
private readonly ILog _logger;
|
||||
private readonly IHttpController _http;
|
||||
private readonly IHttpProvider _http;
|
||||
|
||||
public SabController(IConfigController config, ILog logger, IHttpController http)
|
||||
public SabProvider(IConfigProvider config, ILog logger, IHttpProvider http)
|
||||
{
|
||||
_config = config;
|
||||
_logger = logger;
|
||||
_http = http;
|
||||
}
|
||||
|
||||
#region IDownloadClientController Members
|
||||
#region IDownloadProvider Members
|
||||
|
||||
public bool AddByUrl(ItemInfo nzb)
|
||||
{
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using log4net;
|
||||
using NzbDrone.Core.Helpers;
|
||||
|
@ -7,26 +6,26 @@ using NzbDrone.Core.Repository;
|
|||
using SubSonic.Repository;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SeriesController : ISeriesController
|
||||
public class SeriesProvider : ISeriesProvider
|
||||
{
|
||||
private readonly IConfigController _config;
|
||||
private readonly IDiskController _diskController;
|
||||
private readonly IConfigProvider _config;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly ILog _logger;
|
||||
private readonly IRepository _sonioRepo;
|
||||
private readonly ITvDbController _tvDb;
|
||||
private readonly ITvDbProvider _tvDb;
|
||||
|
||||
public SeriesController(ILog logger, IDiskController diskController, IConfigController configController, IRepository dataRepository, ITvDbController tvDbController)
|
||||
public SeriesProvider(ILog logger, IDiskProvider diskProvider, IConfigProvider configProvider, IRepository dataRepository, ITvDbProvider tvDbProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_diskController = diskController;
|
||||
_config = configController;
|
||||
_diskProvider = diskProvider;
|
||||
_config = configProvider;
|
||||
_sonioRepo = dataRepository;
|
||||
_tvDb = tvDbController;
|
||||
_tvDb = tvDbProvider;
|
||||
}
|
||||
|
||||
#region ISeriesController Members
|
||||
#region ISeriesProvider Members
|
||||
|
||||
public IQueryable<Series> GetSeries()
|
||||
{
|
||||
|
@ -43,7 +42,7 @@ namespace NzbDrone.Core.Controllers
|
|||
public void SyncSeriesWithDisk()
|
||||
{
|
||||
|
||||
foreach (string seriesFolder in _diskController.GetDirectories(_config.SeriesRoot))
|
||||
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
|
||||
{
|
||||
var cleanPath = Disk.CleanPath(new DirectoryInfo(seriesFolder).FullName);
|
||||
if (!_sonioRepo.Exists<Series>(s => s.Path == cleanPath))
|
|
@ -4,19 +4,19 @@ using TvdbLib;
|
|||
using TvdbLib.Cache;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Controllers
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class TvDbController : ITvDbController
|
||||
public class TvDbProvider : ITvDbProvider
|
||||
{
|
||||
private const string TvDbApiKey = "5D2D188E86E07F4F";
|
||||
private readonly TvdbHandler _handler;
|
||||
|
||||
public TvDbController()
|
||||
public TvDbProvider()
|
||||
{
|
||||
_handler = new TvdbHandler(new XmlCacheProvider(Path.Combine(Main.AppPath, @"cache\tvdbcache.xml")), TvDbApiKey);
|
||||
}
|
||||
|
||||
#region ITvDbController Members
|
||||
#region ITvDbProvider Members
|
||||
|
||||
public IList<TvdbSearchResult> SearchSeries(string name)
|
||||
{
|
|
@ -17,6 +17,5 @@ namespace NzbDrone.Core.Repository
|
|||
set;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,31 +3,31 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
public class SeriesController : Controller
|
||||
{
|
||||
private readonly ISeriesController _seriesController;
|
||||
private readonly ISeriesProvider _seriesProvider;
|
||||
//
|
||||
// GET: /Series/
|
||||
|
||||
public SeriesController(ISeriesController seriesController)
|
||||
public SeriesController(ISeriesProvider seriesProvider)
|
||||
{
|
||||
_seriesController = seriesController;
|
||||
_seriesProvider = seriesProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewData.Model = _seriesController.GetSeries().ToList();
|
||||
ViewData.Model = _seriesProvider.GetSeries().ToList();
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
public ActionResult Sync()
|
||||
{
|
||||
_seriesController.SyncSeriesWithDisk();
|
||||
_seriesProvider.SyncSeriesWithDisk();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
public ActionResult Details(int tvdbId)
|
||||
{
|
||||
return View(_seriesController.GetSeries(tvdbId));
|
||||
return View(_seriesProvider.GetSeries(tvdbId));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Controllers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Web.Models;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
|
@ -12,16 +12,16 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
//
|
||||
// GET: /Settings/
|
||||
private IConfigController _configController;
|
||||
private IConfigProvider _configProvider;
|
||||
|
||||
public SettingsController(IConfigController configController)
|
||||
public SettingsController(IConfigProvider configProvider)
|
||||
{
|
||||
_configController = configController;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View(new SettingsModel() { TvFolder = _configController.SeriesRoot });
|
||||
return View(new SettingsModel() { TvFolder = _configProvider.SeriesRoot });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -29,7 +29,7 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_configController.SeriesRoot = model.TvFolder;
|
||||
_configProvider.SeriesRoot = model.TvFolder;
|
||||
//return RedirectToAction("index");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue