public GenerarPDFAnticipoResponseDTO GenerarPDF(int id) { GenerarPDFAnticipoResponseDTO response = new GenerarPDFAnticipoResponseDTO(); response.resultado = _IAnticipoRepository.GenerarPDF(id).ToList(); return(response); }
public IActionResult GenerarPDFAnticipo(int id) { Guid guid = Guid.NewGuid(); _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(id)}"); //ES MOMENTANEO SE DEBE ELIMINAR GenerarPDFAnticipoResponseDTO response = _AnticipoService.GenerarPDF(id); try { string mimetype = ""; int extension = 1; var path = $"{_webHostEnvironment.ContentRootPath}\\Reportes\\rptAnticipo.rdlc"; LocalReport lr = new LocalReport(path); Dictionary <string, string> parameters = new Dictionary <string, string>(); lr.AddDataSource("dsAnticipo", Util.ToDataTable(response.resultado)); var result = lr.Execute(RenderType.Pdf, extension, parameters, mimetype); return(File(result.MainStream, "application/pdf")); } catch (ResultException ex) { response.Result = new Result() { Success = true, ErrCode = ex.Result.ErrCode, Message = ex.Result.Message }; } catch (Exception ex) { response.Result = new Result() { Success = false, Message = "Ocurrio un problema en el servicio, intentelo nuevamente." }; _log.RegistrarEvento(ex, guid.ToString()); } _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(response)}"); return(Ok(response)); }