Ejemplo n.º 1
0
        public async Task <IActionResult> SinglePdfAsync(Dictionary <string, List <int> > ids, CancellationToken cancellationToken)
        {
            InitUserInfo();
            if (!AllowPrint)
            {
                return(ValidationProblem());
            }
            var id   = ids["ids"][0];
            var item = await _purchaseOrderDetailService.GetByIdAsync(id, cancellationToken);

            var result = _purchaseOrderDetailService.GeneratePdf(item, cancellationToken);

            if (result == null)
            {
                AssignToModelState(_purchaseOrderDetailService.Errors);
                return(BadRequest(ModelState));
            }

            var downloadUrl = _uriComposer.ComposeDownloadUri(System.IO.Path.GetFileName(result));
            var pdfResult   = new Dictionary <string, string>()
            {
                { "download", downloadUrl }
            };

            return(Ok(pdfResult));
        }