falta soporte para el menu de propietario de mostrar los archivos

This commit is contained in:
2025-01-19 01:15:06 -03:00
parent 28415f8ba8
commit f5e3c4aacd
10 changed files with 400 additions and 29 deletions
+24
View File
@@ -0,0 +1,24 @@
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;
}
}
+45
View File
@@ -0,0 +1,45 @@
using Entidades;
using Entidades.Dto;
using Microsoft.AspNetCore.Routing.Template;
namespace AlquilaFacil.Facade;
public class DocumentoGeneradorHtml {
public string GenerarHTML(ContratoDto cd, Recibo r) {
string tmpl =$"""
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<div class="container mt-5">
<div class="card">
<div class="card-header text-white bg-primary">
AlquilaFácil
</div>
<div class="card-body">
<h5 class="card-title">Detalles</h5>
<p class="card-text">
<strong>ID:</strong> {cd.id}<br>
<strong>Ubicación:</strong> {cd.Ubicacion}<br>
<strong>Tipo de Propiedad:</strong> {cd.TipoPropiedad}<br>
<strong>Fecha de Inicio:</strong> {cd.Fechainicio}<br>
<strong>Inquilino:</strong> {cd.Inquilino}<br>
<strong>Propietario:</strong> {cd.Propietario}<br>
</p>
<hr>
<h5 class="card-title">Detalles del Recibo</h5>
<p class="card-text">
<strong>ID del Recibo:</strong> {r.Id}<br>
<strong>Fecha:</strong> {r.Fecha}<br>
<strong>Monto:</strong> {r.Monto}<br>
<h2><b>PAGO</b></h2>
</p>
</div>
</div>
</div>
</body>
</html>
"""; return tmpl;
}
}
+67
View File
@@ -0,0 +1,67 @@
using Entidades;
using Entidades.Dto;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
using System.IO;
namespace AlquilaFacil.Facade;
public class DocumentoGeneradorPdf {
public MemoryStream GenerarPdf(ContratoDto cd, Recibo r)
{
var pdfStream = new MemoryStream();
QuestPDF.Settings.License = LicenseType.Community;
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.Header().Text("AlquilaFácil").FontSize(20).SemiBold().FontColor(Colors.White);
page.Content().Column(column =>
{
column.Spacing(10);
column.Item().Border(1).Padding(10).Column(card =>
{
card.Item().Row(row =>
{
row.RelativeItem().Text("Detalles").FontSize(16).SemiBold();
});
card.Item().Column(body =>
{
body.Spacing(5);
body.Item().Text($"ID: {cd.id}").FontSize(12).Bold();
body.Item().Text($"Ubicación: {cd.Ubicacion}").FontSize(12);
body.Item().Text($"Tipo de Propiedad: {cd.TipoPropiedad}").FontSize(12);
body.Item().Text($"Fecha de Inicio: {cd.Fechainicio}").FontSize(12);
body.Item().Text($"Inquilino: {cd.Inquilino}").FontSize(12);
body.Item().Text($"Propietario: {cd.Propietario}").FontSize(12);
});
});
column.Item().Border(1).Padding(10).Column(card =>
{
card.Item().Row(row =>
{
row.RelativeItem().Text("Detalles del Recibo").FontSize(16).SemiBold();
});
card.Item().Column(body =>
{
body.Spacing(5);
body.Item().Text($"ID del Recibo: {r.Id}").FontSize(12).Bold();
body.Item().Text($"Fecha: {r.Fecha}").FontSize(12);
body.Item().Text($"Monto: {r.Monto}").FontSize(12);
body.Item().AlignCenter().Text("PAGO").FontSize(20).Bold();
});
});
});
});
}).GeneratePdf(pdfStream);
pdfStream.Position = 0;
return pdfStream;
}
}