[FA-9] Need to add persistence layer
This commit is contained in:
35
FictionArchive.Service.SchedulerService/GraphQL/Mutation.cs
Normal file
35
FictionArchive.Service.SchedulerService/GraphQL/Mutation.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Data;
|
||||
using FictionArchive.Service.SchedulerService.Models;
|
||||
using FictionArchive.Service.SchedulerService.Services;
|
||||
using HotChocolate.Types;
|
||||
using Quartz;
|
||||
|
||||
namespace FictionArchive.Service.SchedulerService.GraphQL;
|
||||
|
||||
public class Mutation
|
||||
{
|
||||
[Error<DuplicateNameException>]
|
||||
[Error<FormatException>]
|
||||
public async Task<SchedulerJob> ScheduleEventJob(string key, string description, string eventType, string eventData, string cronSchedule, JobManagerService jobManager)
|
||||
{
|
||||
return await jobManager.ScheduleEventJob(key, description, eventType, eventData, cronSchedule);
|
||||
}
|
||||
|
||||
[Error<JobPersistenceException>]
|
||||
public async Task<bool> RunJob(string jobKey, JobManagerService jobManager)
|
||||
{
|
||||
return await jobManager.TriggerJob(jobKey);
|
||||
}
|
||||
|
||||
[Error<KeyNotFoundException>]
|
||||
public async Task<bool> DeleteJob(string jobKey, JobManagerService jobManager)
|
||||
{
|
||||
bool deleted = await jobManager.DeleteJob(jobKey);
|
||||
if (!deleted)
|
||||
{
|
||||
throw new KeyNotFoundException($"Job with key {jobKey} was not found");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user