Exemplo n.º 1
0
        public async Task <IActionResult> CreateReport(PdfReportViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var dto = _mapper.Map <ReportPdfDTO>(viewModel);
                dto.EmailUser = User.GetEmail();
                dto.IpUser    = _accessor.GetIp();
                var result = await _pdfService.CreateReport(dto);

                if (result.IsValid)
                {
                    return(File(result.Result.Data, "application/pdf", $"{result.Result.FileName}.pdf"));
                }
                return(BadRequest());
            }
            return(View("Index", viewModel));
        }