private static bool CanCloseNever(this Job j, JobQueueJob IgnoreJobQueueJob = null)
{
if (!UserService.CurrentAuthorization.Has(Claims.Job.Actions.Close))
return true;
if (j.ClosedDate.HasValue)
return true; // Job already Closed
if (j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue)
return true; // Device not returned to User
if (j.WaitingForUserAction.HasValue)
return true; // Job waiting on User Action
if (j.JobQueues != null)
{
if (IgnoreJobQueueJob == null)
{
if (j.JobQueues.Any(jqj => !jqj.RemovedDate.HasValue))
return true; // Job associated with a Job Queue
}
else
{
if (j.JobQueues.Any(jqj => jqj.Id != IgnoreJobQueueJob.Id && !jqj.RemovedDate.HasValue))
return true; // Job associated with a Job Queue
}
}
return false;
}