diff --git a/EnvelopeGenerator.Web/Controllers/HomeController.cs b/EnvelopeGenerator.Web/Controllers/HomeController.cs index ffd3e8f0..6bef98cb 100644 --- a/EnvelopeGenerator.Web/Controllers/HomeController.cs +++ b/EnvelopeGenerator.Web/Controllers/HomeController.cs @@ -17,6 +17,7 @@ using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; using static EnvelopeGenerator.Common.Constants; using Ganss.Xss; using Newtonsoft.Json; +using EnvelopeGenerator.Application.DTOs; namespace EnvelopeGenerator.Web.Controllers { @@ -188,15 +189,13 @@ namespace EnvelopeGenerator.Web.Controllers if (await _historyService.IsSigned(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress)) return View("EnvelopeSigned"); - if (response.Envelope.Documents.Count > 0) + if (er.Envelope.Documents?.FirstOrDefault() is EnvelopeDocumentDto doc && doc.ByteData is not null) { - var document = await envelopeOldService.GetDocument(response.Envelope.Documents[0].Id, envelopeReceiverId); - byte[] bytes = await envelopeOldService.GetDocumentContents(document); - ViewData["DocumentBytes"] = bytes; + ViewData["DocumentBytes"] = doc.ByteData; } else { - _logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, message: "No document was found."); + _logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, message: "No document byte-data was found in ENVELOPE_DOCUMENT table."); return this.ViewDocumentNotFound(); } @@ -351,12 +350,10 @@ namespace EnvelopeGenerator.Web.Controllers _logger.LogNotice(hist_res.Notices); } - if (response.Envelope.Documents.Count > 0) + if (er.Envelope.Documents?.FirstOrDefault() is EnvelopeDocumentDto doc && doc.ByteData is not null) { - var document = await envelopeOldService.GetDocument(response.Envelope.Documents[0].Id, envelopeKey); - byte[] bytes = await envelopeOldService.GetDocumentContents(document); + ViewData["DocumentBytes"] = doc.ByteData; ViewData["EnvelopeKey"] = envelopeKey; - ViewData["DocumentBytes"] = bytes; ViewData["IsReadOnly"] = true; ViewData["ReadOnly"] = erro; ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"]; @@ -364,7 +361,7 @@ namespace EnvelopeGenerator.Web.Controllers } else { - _logger.LogEnvelopeError(envelopeReceiverId: envelopeKey, message: "No document was found."); + _logger.LogEnvelopeError(envelopeReceiverId: envelopeKey, message: "No document byte-data was found in ENVELOPE_DOCUMENT table."); return this.ViewDocumentNotFound(); } },