示例#1
0
        public async Task <FileResult> GetProtocolAttachment(int protocolAttachmentId)
        {
            var attachment = await _protocolsService.GetAttachmentByIdAsync(protocolAttachmentId);

            if (attachment != null)
            {
                if (!await _authorizationService.CanUserViewProtocolAsync(UserId, attachment.DispatchProtocolId))
                {
                    Unauthorized();
                }

                return(new FileContentResult(attachment.Data, attachment.FileType)
                {
                    FileDownloadName = attachment.FileName
                });
            }

            return(null);
        }
示例#2
0
        public async Task <ActionResult> GetFile(int protocolAttachmentId)
        {
            var result = Ok();

            var attachment = await _protocolsService.GetAttachmentByIdAsync(protocolAttachmentId);

            if (attachment == null)
            {
                return(NotFound());
            }

            var protocol = await _protocolsService.GetProtocolByIdAsync(attachment.DispatchProtocolId);

            if (protocol == null || protocol.DepartmentId != DepartmentId)
            {
                return(Unauthorized());
            }

            return(File(attachment.Data, attachment.FileType));
        }