Sonarr/src/NzbDrone.Core/Tv/SeriesAddedHandler.cs

31 lines
985 B
C#

using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv.Commands;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.Tv
{
public class SeriesAddedHandler : IHandle<SeriesAddedEvent>,
IHandle<SeriesImportedEvent>
{
private readonly IManageCommandQueue _commandQueueManager;
public SeriesAddedHandler(IManageCommandQueue commandQueueManager)
{
_commandQueueManager = commandQueueManager;
}
public void Handle(SeriesAddedEvent message)
{
_commandQueueManager.Push(new RefreshSeriesCommand(new List<int> { message.Series.Id }, true));
}
public void Handle(SeriesImportedEvent message)
{
_commandQueueManager.PushMany(message.SeriesIds.Select(s => new RefreshSeriesCommand(new List<int> { s }, true)).ToList());
}
}
}