private string FindAvailableWorker() { var hosts = new WorkerManager(Database).GetWorkers(); if (hosts == null) { return(null); } var jobManager = new JobManager(Database); if (hosts.Any()) { var jobs = jobManager.GetJobs().Where(a => !a.Completed).ToList(); foreach (var host in hosts) { if (jobs.Any(a => a.AssignedHost == host.Name)) { continue; } return(host.Name); } return(Constants.UNASSIGNED_JOB); } return(Constants.UNASSIGNED_JOB); }