Beispiel #1
0
        public static AttachmentItemModel GetSampleData_AttachmentItem(int attachmentId)
        {
            var result = new AttachmentItemModel
            {
                AttachmentId = attachmentId,
                Filename     = "filename.pdf",
                ContentType  = "application/pdf"
            };

            return(result);
        }
Beispiel #2
0
 public async Task<ActionResult<AttachmentItemModel>> GetAttachmentDetails(int attachmentId)
 {
     if (attachmentId < 0)
     {
         return UnprocessableEntity($"Invalid AttachmentId: {attachmentId}");
     }
     AttachmentItemModel attachmentItem = await _attachmentsService.RetrieveAsync(attachmentId);
     if (attachmentItem is null)
     {
         return NotFound();
     }
     return Ok(attachmentItem);
 }
Beispiel #3
0
 public async Task<IActionResult> DownloadAttachment(int attachmentId)
 {
     if (attachmentId < 1)
     {
         return UnprocessableEntity($"Invalid AttachmentId: {attachmentId}");
     }
     AttachmentItemModel attachmentItem = await _attachmentsService.RetrieveAsync(attachmentId);
     if (attachmentItem is null)
     {
         return NotFound();
     }
     byte[] attachmentFile = await _attachmentsService.DownloadAsync(attachmentId);
     return File(attachmentFile, attachmentItem.ContentType, attachmentItem.Filename);
 }