public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(JobTableItemModel item) { return new ImporterUndetectedDataIdLookupModel { value = item.JobId.ToString(), label = string.Format("{0} ({1}; {2})", item.JobId, item.DeviceSerialNumber, item.UserDisplayName) }; }
private void UpdateJobs(DiscoDataContext Database, List<int> jobIds, JobTableItemModel[] existingItems = null) { lock (updateLock) { // Check for existing items, if not handed them if (existingItems == null) existingItems = base.Items.Where(i => jobIds.Contains(i.JobId)).ToArray(); var updatedItems = this.DetermineItems(Database, this.FilterFunction(Database.Jobs.Where(j => jobIds.Contains(j.Id))), false); var refreshedList = base.Items.ToList(); // Remove Existing if (existingItems.Length > 0) foreach (var existingItem in existingItems) refreshedList.Remove(existingItem); // Add Updated Items if (updatedItems.Count() > 0) foreach (var updatedItem in updatedItems) refreshedList.Add(updatedItem); // Reorder base.Items = this.SortFunction(refreshedList).ToList(); } }