public IActionResult UpdateMods([FromBody] ModsUpdateRequest modsUpdateRequest) { var serverShutdownJob = _hangfireManager .ScheduleJob <ServerStartupService>( x => x.ShutdownServer(2302, false, CancellationToken.None), modsUpdateRequest.ScheduleAt); if (serverShutdownJob.IsFailure) { return(Problem(serverShutdownJob.Error)); } var result = modsUpdateRequest.ModsetName is null ? _hangfireManager.ContinueJobWith <ModsUpdateService>( serverShutdownJob.Value, x => x.UpdateAllMods(CancellationToken.None)) : _hangfireManager.ContinueJobWith <ModsUpdateService>( serverShutdownJob.Value, x => x.UpdateModset(modsUpdateRequest.ModsetName, CancellationToken.None)); return(result.Match( onSuccess: Accepted, onFailure: error => (IActionResult)BadRequest(error))); }
public IActionResult StartServer([FromBody] ServerStartRequest startRequest) { var serverShutdownJob = _hangfireManager .ScheduleJob <ServerStartupService>( x => x.ShutdownServer( startRequest.Port, false, CancellationToken.None), startRequest.ScheduleAt); if (serverShutdownJob.IsFailure) { return(Problem(serverShutdownJob.Error)); } var result = _hangfireManager.ContinueJobWith <ServerStartupService>( serverShutdownJob.Value, x => x.StartServer(startRequest.ModsetName, CancellationToken.None)); return(result.Match( onSuccess: Accepted, onFailure: error => (IActionResult)BadRequest(error))); }