private Job ArrangeJobHooks(Job JobPayload) { JobTask TerminalTask = null; // Hooking up JobTask Predecessors, // validation is skipped due to this is already been recorded in DB for (int count = JobPayload.Tasks.Count - 1; count > 0; count--) { JobPayload.Tasks[count].SetPredecessor(JobPayload.Tasks[count - 1], false); if (JobPayload.Tasks[count].IsTerminatingTask) TerminalTask = JobPayload.Tasks[count]; } TerminalTask = TerminalTask ?? JobPayload.Tasks[0]; JobPayload.TerminalTask = TerminalTask; JobPayload.EnsureTaskAssetEventsAssigned(); JobPayload.EnsureAssetModelsPropagated(); JobPayload.EnsureJobTaskChangeEventsRegistered(isFetchingJobPayload: true); return JobPayload; }