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