@ -27,6 +27,8 @@ namespace NzbDrone.Core.Tv
Series FindByTvdbId ( int tvdbId ) ;
void SetSeriesType ( int seriesId , SeriesTypes seriesTypes ) ;
void DeleteSeries ( int seriesId , bool deleteFiles ) ;
List < Series > GetAllSeries ( ) ;
void UpdateSeries ( Series series ) ;
}
public class SeriesService : ISeriesService , IHandleAsync < SeriesAddedEvent >
@ -35,19 +37,19 @@ namespace NzbDrone.Core.Tv
private readonly IConfigService _configService ;
private readonly IProvideSeriesInfo _seriesInfoProxy ;
private readonly IEventAggregator _eventAggregator ;
private readonly I BasicRepository< RootFolder > _rootFolderRepository ;
private readonly I RootFolderService _rootFolderService ;
private readonly DiskProvider _diskProvider ;
private readonly Logger _logger ;
public SeriesService ( ISeriesRepository seriesRepository , IConfigService configServiceService ,
IProvideSeriesInfo seriesInfoProxy , IEventAggregator eventAggregator ,
I BasicRepository< RootFolder > rootFolderRepository , DiskProvider diskProvider , Logger logger )
I RootFolderService rootFolderService , DiskProvider diskProvider , Logger logger )
{
_seriesRepository = seriesRepository ;
_configService = configServiceService ;
_seriesInfoProxy = seriesInfoProxy ;
_eventAggregator = eventAggregator ;
_rootFolder Repository = rootFolderRepository ;
_rootFolder Service = rootFolderService ;
_diskProvider = diskProvider ;
_logger = logger ;
}
@ -94,7 +96,7 @@ namespace NzbDrone.Core.Tv
if ( String . IsNullOrWhiteSpace ( newSeries . FolderName ) )
{
newSeries . FolderName = FileNameBuilder . CleanFilename ( newSeries . Title ) ;
_diskProvider . CreateDirectory ( Path . Combine ( _rootFolder Repository . Get ( newSeries . RootFolderId ) . Path , newSeries . FolderName ) ) ;
_diskProvider . CreateDirectory ( Path . Combine ( _rootFolder Service . Get ( newSeries . RootFolderId ) . Path , newSeries . FolderName ) ) ;
}
_logger . Info ( "Adding Series [{0}] Path: [{1}]" , newSeries . Title , newSeries . Path ) ;
@ -153,6 +155,16 @@ namespace NzbDrone.Core.Tv
_eventAggregator . Publish ( new SeriesDeletedEvent ( series , deleteFiles ) ) ;
}
public List < Series > GetAllSeries ( )
{
return _seriesRepository . All ( ) . ToList ( ) ;
}
public void UpdateSeries ( Series series )
{
_seriesRepository . Update ( series ) ;
}
public void HandleAsync ( SeriesAddedEvent message )
{
UpdateSeriesInfo ( message . Series . Id ) ;