Beispiel #1
0
        public async Task <IActionResult> Post([FromForm] UploadDocumentCommand command)
        {
            command.UserId = User.Identity.GetProfileId();
            var response = await Mediator.Send(command);

            if (!response.Status)
            {
                return(BadRequest(response));
            }

            return(Created("", response));
        }
Beispiel #2
0
        public async Task <ActionResult <PhysicalDocumentReferenceDto> > UploadDraftDocument(string company, [FromForm, Required] UploadDocumentCommand request, [FromForm, Required] IFormFile file)
        {
            long documentId;
            var  tables = await _applicationTableQueries.GetApplicationTablesAsync(request.PhysicalDocumentTypeId.GetApplicationTableName());

            request.TableId = tables.First().TableId;

            using (var stream = new MemoryStream())
            {
                await file.CopyToAsync(stream);

                request.CompanyId    = company;
                request.DocumentName = request.DocumentName ?? file.FileName;
                request.IsDraft      = true;
                request.File         = stream.ToArray();

                documentId = await _mediator.Send(request);
            }

            return(CreatedAtAction(nameof(GetGeneratedDocumentById), new { physicalDocumentId = documentId }, new PhysicalDocumentReferenceDto {
                PhysicalDocumentId = documentId
            }));
        }