I have a list of jobs and they have their data. Also, I have an API to change their data source (LastParsedBlock) and I want it to stop that specific job when I change the data and start all the processes from the beginning and I don't want it to wait for it to complete.
[HttpPut("LastParsedBlock")]
public async Task<ActionResult> ChangeLastParsedBlockAsync([FromBody] ChangeLastParsedBlockDto dto)
{
var jobkey = new JobKey(dto.CoinId.ToString());
var scheduler = await _schedulerFactory.GetScheduler();
var jobDetail = await scheduler.GetJobDetail(jobkey);
if (jobDetail != null)
await scheduler.PauseJob(jobkey);
var handler = Handlers.SingleOrDefault(x => x.Id == dto.CoinId);
handler.LastParsedBlock = dto.NewLastParsedBlock; //changing data source
await scheduler.ResumeJob(jobkey); //it doesn't restart, just resumes
return Ok($"Changed successfuly.");
}