Files
AlquilaFacil/Aspnet/Facade/DocumentoFacade.cs

24 lines
787 B
C#

using System.Runtime;
using System.Text;
using Entidades;
using Entidades.Dto;
namespace AlquilaFacil.Facade;
public class DocumentoFacade {
private readonly DocumentoGeneradorHtml d1 = new();
private readonly DocumentoGeneradorPdf d2 = new();
public void GenerarHtml(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
string str = d1.GenerarHTML(cd, r);
StreamWriter writer = new StreamWriter(memoryStream, Encoding.UTF8);
writer.WriteAsync(str).Wait();
writer.FlushAsync().Wait();
memoryStream.Position = 0;
}
public void GenerarPdf(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
var mem = d2.GenerarPdf(cd, r);
mem.CopyToAsync(memoryStream).Wait();
memoryStream.Position = 0;
}
}