From 190ce6b142882bacb9865c2717609f1ac3760b4b Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 16 Jun 2011 19:27:10 -0700 Subject: [PATCH] ConfigProvider now uses PetaPoco --- NzbDrone.Core.Test/ConfigProviderTest.cs | 76 +++++++++++++------ NzbDrone.Core.Test/Framework/MockLib.cs | 2 - .../Datastore/Migrations/MigrationExport.cs | 6 ++ .../Providers/Core/ConfigProvider.cs | 40 +++++----- .../XbmcNotificationProvider.cs | 18 ++--- NzbDrone.Core/Providers/SeriesProvider.cs | 43 +++++------ NzbDrone.Core/Providers/XbmcProvider.cs | 16 ++-- NzbDrone.Core/Repository/Config.cs | 6 +- NzbDrone.Core/Repository/Series.cs | 1 + .../Controllers/SettingsController.cs | 30 ++++---- 10 files changed, 132 insertions(+), 106 deletions(-) diff --git a/NzbDrone.Core.Test/ConfigProviderTest.cs b/NzbDrone.Core.Test/ConfigProviderTest.cs index e67e19055..bc2805f40 100644 --- a/NzbDrone.Core.Test/ConfigProviderTest.cs +++ b/NzbDrone.Core.Test/ConfigProviderTest.cs @@ -1,4 +1,5 @@ using AutoMoq; +using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.Providers.Core; @@ -13,52 +14,81 @@ namespace NzbDrone.Core.Test public class ConfigProviderTest : TestBase { [Test] - public void Overwrite_existing_value() + public void Add_new_value_to_database() { const string key = "MY_KEY"; const string value = "MY_VALUE"; - //Arrange - var config = new Config {Key = key, Value = value}; - var mocker = new AutoMoqer(); - - mocker.GetMock() - .Setup(r => r.Single(key)) - .Returns(config); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); //Act mocker.Resolve().SetValue(key, value); //Assert - mocker.GetMock().Verify(c => c.Update(config)); - mocker.GetMock().Verify(c => c.Add(It.IsAny()), Times.Never()); + mocker.Resolve().GetValue(key, "").Should().Be(value); } [Test] - public void Add_new_value() + public void Get_value_from_database() { const string key = "MY_KEY"; const string value = "MY_VALUE"; - //Arrange var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); - mocker.GetMock() - .Setup(r => r.Single(It.IsAny())) - .Returns(null) - .Verifiable(); + db.Insert(new Config { Key = key, Value = value }); //Act - mocker.Resolve().SetValue(key, value); + var result = mocker.Resolve().GetValue(key, ""); //Assert - mocker.GetMock().Verify(); - mocker.GetMock().Verify(r => r.Update(It.IsAny()), Times.Never()); - mocker.GetMock().Verify(r => r.Add(It.Is(c => c.Key == key && c.Value == value)), - Times.Once()); - - Assert.Pass(); + result.Should().Be(value); } + + + [Test] + public void Get_value_should_return_default_when_no_value() + { + const string key = "MY_KEY"; + const string value = "MY_VALUE"; + + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + + //Act + var result = mocker.Resolve().GetValue(key, value); + + //Assert + result.Should().Be(value); + } + + [Test] + public void New_value_should_update_old_value() + { + const string key = "MY_KEY"; + const string originalValue = "OLD_VALUE"; + const string newValue = "NEW_VALUE"; + + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + db.Insert(new Config { Key = key, Value = originalValue }); + + //Act + mocker.Resolve().SetValue(key, newValue); + var result = mocker.Resolve().GetValue(key, ""); + + //Assert + result.Should().Be(newValue); + db.Fetch().Should().HaveCount(1); + } + } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/Framework/MockLib.cs b/NzbDrone.Core.Test/Framework/MockLib.cs index 9adc0f271..85c4cb554 100644 --- a/NzbDrone.Core.Test/Framework/MockLib.cs +++ b/NzbDrone.Core.Test/Framework/MockLib.cs @@ -126,8 +126,6 @@ namespace NzbDrone.Core.Test.Framework private static void ForceMigration(IRepository repository) { - repository.All().Count(); - repository.All().Count(); repository.All().Count(); repository.All().Count(); repository.All().Count(); diff --git a/NzbDrone.Core/Datastore/Migrations/MigrationExport.cs b/NzbDrone.Core/Datastore/Migrations/MigrationExport.cs index 524415601..39405ff11 100644 --- a/NzbDrone.Core/Datastore/Migrations/MigrationExport.cs +++ b/NzbDrone.Core/Datastore/Migrations/MigrationExport.cs @@ -45,6 +45,12 @@ namespace NzbDrone.Core.Datastore.Migrations .WithNullableColumn("GrabDate", DbType.DateTime); + db.CreateTable("Config") + .WithNotNullableColumn("Key", DbType.String).Unique() + .WithNotNullableColumn("Value", DbType.String); + + + } } diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index f1afecabb..50fc4c8d7 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -5,6 +5,7 @@ using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Repository; +using PetaPoco; using SubSonic.Repository; namespace NzbDrone.Core.Providers.Core @@ -12,17 +13,18 @@ namespace NzbDrone.Core.Providers.Core public class ConfigProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _repository; + private readonly IDatabase _database; + [Inject] - public ConfigProvider(IRepository repository) + public ConfigProvider(IDatabase database) { - _repository = repository; + _database = database; } public IList All() { - return _repository.All().ToList(); + return _database.Fetch(); } public ConfigProvider() @@ -129,7 +131,7 @@ namespace NzbDrone.Core.Providers.Core public virtual String SabHost { - get { return GetValue("SabHost", "localhost", true); } + get { return GetValue("SabHost", "localhost"); } set { SetValue("SabHost", value); } } @@ -164,7 +166,7 @@ namespace NzbDrone.Core.Providers.Core public virtual String SabTvCategory { - get { return GetValue("SabTvCategory", "TV", false); } + get { return GetValue("SabTvCategory", "TV"); } set { SetValue("SabTvCategory", value); } } @@ -178,7 +180,7 @@ namespace NzbDrone.Core.Providers.Core public virtual String SabDropDirectory { - get { return GetValue("SabTvDropDirectory", "", false); } + get { return GetValue("SabTvDropDirectory"); } set { SetValue("SabTvDropDirectory", value); } } @@ -230,7 +232,7 @@ namespace NzbDrone.Core.Providers.Core public virtual string SeasonFolderFormat { - get { return GetValue("Sorting_SeasonFolderFormat", "Season %s", false); } + get { return GetValue("Sorting_SeasonFolderFormat", "Season %s"); } set { SetValue("Sorting_SeasonFolderFormat", value); } } @@ -261,31 +263,29 @@ namespace NzbDrone.Core.Providers.Core private string GetValue(string key) { - return GetValue(key, String.Empty, false); + return GetValue(key, String.Empty); } private bool GetValueBoolean(string key, bool defaultValue = false) { - return Convert.ToBoolean(GetValue(key, defaultValue, false)); + return Convert.ToBoolean(GetValue(key, defaultValue)); } private int GetValueInt(string key, int defaultValue = 0) { - return Convert.ToInt16(GetValue(key, defaultValue, false)); + return Convert.ToInt16(GetValue(key, defaultValue)); } - public virtual string GetValue(string key, object defaultValue, bool makePermanent) + public virtual string GetValue(string key, object defaultValue) { string value; - var dbValue = _repository.Single(key); + var dbValue = _database.SingleOrDefault(key); if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) return dbValue.Value; Logger.Debug("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue); - if (makePermanent) - SetValue(key, defaultValue.ToString()); value = defaultValue.ToString(); return value; @@ -310,20 +310,16 @@ namespace NzbDrone.Core.Providers.Core Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value); - var dbValue = _repository.Single(key); + var dbValue = _database.SingleOrDefault("WHERE KEY=@0", key); if (dbValue == null) { - _repository.Add(new Config - { - Key = key, - Value = value - }); + _database.Insert(new Config { Key = key, Value = value }); } else { dbValue.Value = value; - _repository.Update(dbValue); + _database.Update(dbValue); } } } diff --git a/NzbDrone.Core/Providers/ExternalNotification/XbmcNotificationProvider.cs b/NzbDrone.Core/Providers/ExternalNotification/XbmcNotificationProvider.cs index bcb2bd369..8edcade41 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/XbmcNotificationProvider.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/XbmcNotificationProvider.cs @@ -23,9 +23,9 @@ namespace NzbDrone.Core.Providers.ExternalNotification { const string header = "NzbDrone [TV] - Grabbed"; - if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false))) { - if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false))) { _logger.Trace("Sending Notification to XBMC"); _xbmcProvider.Notify(header, message); @@ -41,21 +41,21 @@ namespace NzbDrone.Core.Providers.ExternalNotification { const string header = "NzbDrone [TV] - Downloaded"; - if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false))) { - if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false))) { _logger.Trace("Sending Notification to XBMC"); _xbmcProvider.Notify(header, message); } - if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false))) { _logger.Trace("Sending Update Request to XBMC"); _xbmcProvider.Update(seriesId); } - if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false))) { _logger.Trace("Sending Clean DB Request to XBMC"); _xbmcProvider.Clean(); @@ -69,19 +69,19 @@ namespace NzbDrone.Core.Providers.ExternalNotification { const string header = "NzbDrone [TV] - Renamed"; - if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false))) { _logger.Trace("Sending Notification to XBMC"); _xbmcProvider.Notify(header, message); } - if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false))) { _logger.Trace("Sending Update Request to XBMC"); _xbmcProvider.Update(seriesId); } - if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false))) { _logger.Trace("Sending Clean DB Request to XBMC"); _xbmcProvider.Clean(); diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 4a3e276f6..58cedec79 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -8,9 +8,7 @@ using NLog; using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Quality; using PetaPoco; -using SubSonic.Repository; using TvdbLib.Data; namespace NzbDrone.Core.Providers @@ -18,17 +16,15 @@ namespace NzbDrone.Core.Providers public class SeriesProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly IRepository _repository; private readonly ConfigProvider _configProvider; private readonly TvDbProvider _tvDbProvider; private readonly IDatabase _database; private readonly QualityProvider _qualityProvider; [Inject] - public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository, TvDbProvider tvDbProviderProvider, IDatabase database, QualityProvider qualityProvider) + public SeriesProvider(ConfigProvider configProviderProvider, TvDbProvider tvDbProviderProvider, IDatabase database, QualityProvider qualityProvider) { _configProvider = configProviderProvider; - _repository = repository; _tvDbProvider = tvDbProviderProvider; _database = database; _qualityProvider = qualityProvider; @@ -100,7 +96,7 @@ namespace NzbDrone.Core.Providers repoSeries.Monitored = true; //New shows should be monitored repoSeries.QualityProfileId = qualityProfileId; if (qualityProfileId == 0) - repoSeries.QualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true)); + repoSeries.QualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1")); repoSeries.SeasonFolder = _configProvider.UseSeasonFolder; @@ -127,30 +123,29 @@ namespace NzbDrone.Core.Providers public virtual void DeleteSeries(int seriesId) { - Logger.Warn("Deleting Series [{0}]", seriesId); - var series = _repository.Single(seriesId); + var series = GetSeries(seriesId); + Logger.Warn("Deleting Series [{0}]", series.Title); - //Delete Files, Episodes, Seasons then the Series - //Can't use providers because episode provider needs series provider - Cyclic Dependency Injection, this will work + using (var tran = _database.GetTransaction()) + { + //Delete History, Files, Episodes, Seasons then the Series - //Delete History Items for any episodes that belong to this series - Logger.Debug("Deleting History Items from DB for Series: {0}", series.SeriesId); - var episodes = series.Episodes.Select(e => e.EpisodeId).ToList(); - episodes.ForEach(e => _repository.DeleteMany(h => h.EpisodeId == e)); + Logger.Debug("Deleting History Items from DB for Series: {0}", series.Title); + _database.Delete("WHERE SeriesId=@0", seriesId); - //Delete all episode files from the DB for episodes in this series - Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.SeriesId); - _repository.DeleteMany(series.EpisodeFiles); + Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.Title); + _database.Delete("WHERE SeriesId=@0", seriesId); - //Delete all episodes for this series from the DB - Logger.Debug("Deleting Episodes from DB for Series: {0}", series.SeriesId); - _repository.DeleteMany(series.Episodes); + Logger.Debug("Deleting Episodes from DB for Series: {0}", series.Title); + _database.Delete("WHERE SeriesId=@0", seriesId); - //Delete the Series - Logger.Debug("Deleting Series from DB {0}", series.Title); - _repository.Delete(seriesId); + Logger.Debug("Deleting Series from DB {0}", series.Title); + _database.Delete("WHERE SeriesId=@0", seriesId); - Logger.Info("Successfully deleted Series [{0}]", seriesId); + Logger.Info("Successfully deleted Series [{0}]", series.Title); + + tran.Complete(); + } } public virtual bool SeriesPathExists(string cleanPath) diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index 109106e5a..95766b33e 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -25,10 +25,10 @@ namespace NzbDrone.Core.Providers public virtual void Notify(string header, string message) { //Get time in seconds and convert to ms - var time = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", "3", true)) * 1000; + var time = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", "3")) * 1000; var command = String.Format("ExecBuiltIn(Notification({0},{1},{2}))", header, message, time); - if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true))) + if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false))) { //Todo: Get the actual port that NzbDrone is running on... var serverInfo = String.Format("http://{0}:{1}", Environment.MachineName, "8989"); @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Providers command = String.Format("ExecBuiltIn(Notification({0},{1},{2}, {3}))", header, message, time, imageUrl); } - foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(',')) { Logger.Trace("Sending Notifcation to XBMC Host: {0}", host); SendCommand(host, command); @@ -46,14 +46,14 @@ namespace NzbDrone.Core.Providers public virtual void Update(int seriesId) { - foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(',')) { Logger.Trace("Sending Update DB Request to XBMC Host: {0}", host); var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId); //If the path is not found & the user wants to update the entire library, do it now. if (String.IsNullOrEmpty(xbmcSeriesPath) && - Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true))) + Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false))) { //Update the entire library Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host); @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Providers public virtual void Clean() { - foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(',')) + foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(',')) { Logger.Trace("Sending DB Clean Request to XBMC Host: {0}", host); var command = String.Format("ExecBuiltIn(CleanLibrary(video))"); @@ -78,8 +78,8 @@ namespace NzbDrone.Core.Providers private string SendCommand(string host, string command) { - var username = _configProvider.GetValue("XbmcUsername", String.Empty, true); - var password = _configProvider.GetValue("XbmcPassword", String.Empty, true); + var username = _configProvider.GetValue("XbmcUsername", String.Empty); + var password = _configProvider.GetValue("XbmcPassword", String.Empty); var url = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", host, command); if (!String.IsNullOrEmpty(username)) diff --git a/NzbDrone.Core/Repository/Config.cs b/NzbDrone.Core/Repository/Config.cs index 898b69cf5..643928d67 100644 --- a/NzbDrone.Core/Repository/Config.cs +++ b/NzbDrone.Core/Repository/Config.cs @@ -1,11 +1,11 @@ -using SubSonic.SqlGeneration.Schema; +using PetaPoco; +using SubSonic.SqlGeneration.Schema; namespace NzbDrone.Core.Repository { - [SubSonicTableNameOverride("Config")] + [PrimaryKey("Key", autoIncrement = false)] public class Config { - [SubSonicPrimaryKey] public string Key { get; set; } public string Value { get; set; } diff --git a/NzbDrone.Core/Repository/Series.cs b/NzbDrone.Core/Repository/Series.cs index ed20a92c4..1d8767c17 100644 --- a/NzbDrone.Core/Repository/Series.cs +++ b/NzbDrone.Core/Repository/Series.cs @@ -7,6 +7,7 @@ using SubSonic.SqlGeneration.Schema; namespace NzbDrone.Core.Repository { + [PrimaryKey("SeriesId", autoIncrement = false)] public class Series { [SubSonicPrimaryKey(false)] diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 335c7eda9..528a0fd0d 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -148,20 +148,20 @@ namespace NzbDrone.Web.Controllers var model = new NotificationSettingsModel { - XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)), - XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)), - XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)), - XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)), - XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)), - XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)), - XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)), - XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)), - XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)), - XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)), - XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)), - XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true), - XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true), - XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true) + XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)), + XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false)), + XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false)), + XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false)), + XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false)), + XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3)), + XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false)), + XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false)), + XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false)), + XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false)), + XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false)), + XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80"), + XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty), + XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty) }; return View("Index", model); @@ -240,7 +240,7 @@ namespace NzbDrone.Web.Controllers { var profiles = _qualityProvider.GetAllProfiles().ToList(); var defaultQualityQualityProfileId = - Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true)); + Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId)); var selectList = new SelectList(profiles, "QualityProfileId", "Name"); return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };