ExternalNotificationProvider moved to Peta.

pull/6/head
Mark McDowall 13 years ago
parent f7ee16dbba
commit 901db9d58b

@ -108,6 +108,14 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey), new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
new Column("Path", DbType.String, ColumnProperty.NotNull), new Column("Path", DbType.String, ColumnProperty.NotNull),
}); });
Database.AddTable("ExternalNotificationSettings", "SQLite", new[]
{
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
new Column("Enabled", DbType.Boolean, ColumnProperty.NotNull),
new Column("NotifierName", DbType.String, ColumnProperty.NotNull),
new Column("Name", DbType.String, ColumnProperty.NotNull)
});
} }
public override void Down() public override void Down()

@ -8,6 +8,7 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification; using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository; using SubSonic.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
@ -15,12 +16,12 @@ namespace NzbDrone.Core.Providers
public class ExternalNotificationProvider public class ExternalNotificationProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository; private readonly IDatabase _database;
[Inject] [Inject]
public ExternalNotificationProvider(IRepository repository) public ExternalNotificationProvider(IDatabase database)
{ {
_repository = repository; _database = database;
} }
public ExternalNotificationProvider() public ExternalNotificationProvider()
@ -30,7 +31,7 @@ namespace NzbDrone.Core.Providers
public virtual List<ExternalNotificationSetting> All() public virtual List<ExternalNotificationSetting> All()
{ {
return _repository.All<ExternalNotificationSetting>().ToList(); return _database.Fetch<ExternalNotificationSetting>();
} }
public virtual void SaveSettings(ExternalNotificationSetting settings) public virtual void SaveSettings(ExternalNotificationSetting settings)
@ -38,23 +39,24 @@ namespace NzbDrone.Core.Providers
if (settings.Id == 0) if (settings.Id == 0)
{ {
Logger.Debug("Adding External Notification settings for {0}", settings.Name); Logger.Debug("Adding External Notification settings for {0}", settings.Name);
_repository.Add(settings); _database.Insert(settings);
} }
else else
{ {
Logger.Debug("Updating External Notification settings for {0}", settings.Name); Logger.Debug("Updating External Notification settings for {0}", settings.Name);
_repository.Update(settings); _database.Update(settings);
} }
} }
public virtual ExternalNotificationSetting GetSettings(Type type) public virtual ExternalNotificationSetting GetSettings(Type type)
{ {
return _repository.Single<ExternalNotificationSetting>(s => s.NotifierName == type.ToString()); return _database.SingleOrDefault<ExternalNotificationSetting>("WHERE NotifierName = @0", type.ToString());
} }
public virtual ExternalNotificationSetting GetSettings(int id) public virtual ExternalNotificationSetting GetSettings(int id)
{ {
return _repository.Single<ExternalNotificationSetting>(s => s.Id == id); return _database.SingleOrDefault<ExternalNotificationSetting>(id);
} }
public virtual void InitializeNotifiers(IList<ExternalNotificationProviderBase> notifiers) public virtual void InitializeNotifiers(IList<ExternalNotificationProviderBase> notifiers)

@ -2,17 +2,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using SubSonic.SqlGeneration.Schema; using PetaPoco;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
[TableName("ExternalNotificationSettings")]
[PrimaryKey("Id", autoIncrement = true)]
public class ExternalNotificationSetting public class ExternalNotificationSetting
{ {
[SubSonicPrimaryKey(true)]
public int Id { get; set; } public int Id { get; set; }
public bool Enabled { get; set; } public bool Enabled { get; set; }
public string NotifierName { get; set; } public string NotifierName { get; set; }
public string Name { get; set; } public string Name { get; set; }
} }
} }

Loading…
Cancel
Save