1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-21 01:49:57 +02:00
Sonarr/NzbDrone.Core/Jobs/JobRepository.cs
2013-09-14 16:34:21 -07:00

41 lines
1.1 KiB
C#

using System;
using System.Linq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Jobs
{
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
{
ScheduledTask GetDefinition(Type type);
void SetLastExecutionTime(int id, DateTime executionTime);
}
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
{
public ScheduledTaskRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
public ScheduledTask GetDefinition(Type type)
{
return Query.Single(c => c.TypeName == type.FullName);
}
public void SetLastExecutionTime(int id, DateTime executionTime)
{
var task = new ScheduledTask
{
Id = id,
LastExecution = executionTime
};
SetFields(task, scheduledTask => scheduledTask.LastExecution);
}
}
}