public QueueItemViewModel GetQueueItemView(QueueItem queueItem) { QueueItemViewModel queueItemViewModel = new QueueItemViewModel(); queueItemViewModel = queueItemViewModel.Map(queueItem); var attachmentsList = _queueItemAttachmentRepository.Find(null, q => q.QueueItemId == queueItem.Id)?.Items; if (attachmentsList != null) { queueItemViewModel.Attachments = attachmentsList; } else { queueItemViewModel.Attachments = null; } return(queueItemViewModel); }
public QueueItemViewModel GetQueueItemView(QueueItemViewModel queueItemView, string id) { var attachmentsList = queueItemAttachmentRepository.Find(null, q => q.QueueItemId == Guid.Parse(id))?.Items; if (attachmentsList != null) { List <Guid?> binaryObjectIds = new List <Guid?>(); foreach (var item in attachmentsList) { binaryObjectIds.Add(item.BinaryObjectId); } queueItemView.BinaryObjectIds = binaryObjectIds; } else { queueItemView.BinaryObjectIds = null; } return(queueItemView); }
public async Task <IActionResult> Delete(string id) { Guid queueItemId = new Guid(id); QueueItem existingQueueItem = repository.GetOne(queueItemId); if (existingQueueItem == null) { ModelState.AddModelError("QueueItem", "QueueItem cannot be found or does not exist."); return(NotFound(ModelState)); } if (existingQueueItem.IsLocked) { ModelState.AddModelError("Delete", "Queue Item is locked at this time and cannot be deleted"); return(BadRequest(ModelState)); } await webhookPublisher.PublishAsync("QueueItems.QueueItemDeleted", existingQueueItem.Id.ToString(), existingQueueItem.Name).ConfigureAwait(false); var response = await base.DeleteEntity(id); _hub.Clients.All.SendAsync("sendnotification", "QueueItem deleted."); //soft delete each queue item attachment entity and binary object entity that correlates to the queue item var attachmentsList = queueItemAttachmentRepository.Find(null, q => q.QueueItemId == existingQueueItem.Id)?.Items; foreach (var attachment in attachmentsList) { queueItemAttachmentRepository.SoftDelete((Guid)attachment.Id); var existingBinary = binaryObjectRepository.GetOne(attachment.BinaryObjectId); if (existingBinary != null) { await webhookPublisher.PublishAsync("Files.FileDeleted", existingBinary.Id.ToString(), existingBinary.Name).ConfigureAwait(false); } binaryObjectRepository.SoftDelete(attachment.BinaryObjectId); } return(response); }