falta armar una ultima notificacion para el inquilino y setear el front para que mande las request bien
This commit is contained in:
36
Aspnet/Builder/DtoBuilder/GaranteDtoBuilder.cs
Normal file
36
Aspnet/Builder/DtoBuilder/GaranteDtoBuilder.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using Entidades.Dto;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Builder;
|
||||||
|
public class GaranteDtoBuilder : Builder<GaranteDto> {
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetDni (long Dni) {
|
||||||
|
data.Dni = Dni;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetNombre (string Nombre) {
|
||||||
|
data.Nombre = Nombre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetApellido (string Apellido) {
|
||||||
|
data.Apellido = Apellido;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetDomicilio (string Domicilio) {
|
||||||
|
data.Domicilio = Domicilio;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetCelular (string Celular) {
|
||||||
|
data.Celular = Celular;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteDtoBuilder SetDomicilioLaboral (string Domiciliolaboral) {
|
||||||
|
data.Domiciliolaboral = Domiciliolaboral;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
Aspnet/Config/MinioConfig.cs
Normal file
5
Aspnet/Config/MinioConfig.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace AlquilaFacil.Config;
|
||||||
|
public class MinioConfigcus {
|
||||||
|
public string usr { get; set; } ="";
|
||||||
|
public string scrt { get; set; } = "";
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@ using AlquilaFacil.Builder;
|
|||||||
using Entidades;
|
using Entidades;
|
||||||
using Entidades.Dto;
|
using Entidades.Dto;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Minio;
|
||||||
|
using Minio.DataModel;
|
||||||
|
using Minio.DataModel.Args;
|
||||||
|
using Minio.Exceptions;
|
||||||
using Modelo;
|
using Modelo;
|
||||||
|
|
||||||
namespace AlquilaFacil.Controllers;
|
namespace AlquilaFacil.Controllers;
|
||||||
@@ -191,11 +195,27 @@ public class ContratoController: ControllerBase {
|
|||||||
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
||||||
if (contr == null) return BadRequest(new {message = "No hay un precontrato por esa id"});
|
if (contr == null) return BadRequest(new {message = "No hay un precontrato por esa id"});
|
||||||
|
|
||||||
return Ok(contr.Idgarantes);
|
LinkedList<GaranteDto> list = new();
|
||||||
|
foreach (var i in contr.Idgarantes) {
|
||||||
|
list.AddFirst(new GaranteDtoBuilder()
|
||||||
|
.SetCelular(i.Celular)
|
||||||
|
.SetDni(i.Dni)
|
||||||
|
.SetDomicilio(i.Domicilio)
|
||||||
|
.SetDomicilioLaboral(i.Domiciliolaboral)
|
||||||
|
.SetNombre(i.Nombre)
|
||||||
|
.SetApellido(i.Apellido)
|
||||||
|
.Build());
|
||||||
|
}
|
||||||
|
return Ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IMinioClient mc;
|
||||||
|
public ContratoController(IMinioClient mcc){
|
||||||
|
mc = mcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/contratos/subirContrato")]
|
[HttpPost("api/contratos/subirContrato")]
|
||||||
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato =0, IFormFile contrato) {
|
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato, IFormFile contrato) {
|
||||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -209,14 +229,11 @@ public class ContratoController: ControllerBase {
|
|||||||
if (!Path.GetExtension(contrato.FileName).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) return BadRequest(new { message = "El archivo debe tener la extensión .pdf." });
|
if (!Path.GetExtension(contrato.FileName).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) return BadRequest(new { message = "El archivo debe tener la extensión .pdf." });
|
||||||
|
|
||||||
string nuevoNombreArchivo = $"id:{contr.Id}-inq:{contr.Dniinquilino}-propi:{contr.Dnipropietario}-idprop:{contr.Idpropiedad}.pdf";
|
string nuevoNombreArchivo = $"id:{contr.Id}-inq:{contr.Dniinquilino}-propi:{contr.Dnipropietario}-idprop:{contr.Idpropiedad}.pdf";
|
||||||
|
|
||||||
var s3Client = new AmazonS3Client("aVO9C3PqeK1hiPCyqZCj", "szj58kceWG3GcRZ8P1QCQiv5tSjMI7iD5zfjneTT", new AmazonS3Config
|
|
||||||
{
|
|
||||||
ServiceURL = "http://192.168.1.11",
|
|
||||||
ForcePathStyle = true
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var ret = subirContrato(contrato, mc, nuevoNombreArchivo).Wait();
|
||||||
|
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/contratos/aceptarContrato")]
|
[HttpPost("api/contratos/aceptarContrato")]
|
||||||
@@ -228,6 +245,32 @@ public class ContratoController: ControllerBase {
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<bool> subirContrato(IFormFile f, IMinioClient m, string flname) {
|
||||||
|
try {
|
||||||
|
var buck = new BucketExistsArgs().WithBucket("alquilafacil");
|
||||||
|
bool encontrado = await m.BucketExistsAsync(buck).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if(!encontrado){
|
||||||
|
var mb = new MakeBucketArgs().WithBucket("alquilafacil");
|
||||||
|
await m.MakeBucketAsync(mb).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
using (var stream = f.OpenReadStream()){
|
||||||
|
|
||||||
|
var putbj = new PutObjectArgs()
|
||||||
|
.WithBucket("alquilafacil")
|
||||||
|
.WithObject(flname)
|
||||||
|
.WithStreamData(stream)
|
||||||
|
.WithContentType("application/pdf")
|
||||||
|
.WithObjectSize(f.Length);
|
||||||
|
await m.PutObjectAsync(putbj).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (MinioException e ) {
|
||||||
|
Console.Error.WriteLine(e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string ValidarCancelarDto(CancelarPrecontratoDto dto) {
|
private string ValidarCancelarDto(CancelarPrecontratoDto dto) {
|
||||||
if (dto == null) return "dto nulo";
|
if (dto == null) return "dto nulo";
|
||||||
string ret = "";
|
string ret = "";
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using Minio;
|
||||||
|
using AlquilaFacil.Config;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
|
||||||
|
MinioConfigcus? mcon = JsonSerializer.Deserialize<MinioConfigcus>(File.ReadAllText("./settings.json"))?? null;
|
||||||
|
if (mcon == null) return;
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
|
builder.Services.AddMinio(confi => confi
|
||||||
|
.WithCredentials(mcon.usr, mcon.scrt)
|
||||||
|
.WithEndpoint("http://192.168.1.11:9000")
|
||||||
|
.Build());
|
||||||
|
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
|||||||
4
Aspnet/bin/Debug/net8.0/settings.json
Normal file
4
Aspnet/bin/Debug/net8.0/settings.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usr":"aVO9C3PqeK1hiPCyqZCj",
|
||||||
|
"scrt":"szj58kceWG3GcRZ8P1QCQiv5tSjMI7iD5zfjneTT"
|
||||||
|
}
|
||||||
@@ -7,11 +7,25 @@
|
|||||||
garantes: GaranteDto[],
|
garantes: GaranteDto[],
|
||||||
onCancel:()=>void,
|
onCancel:()=>void,
|
||||||
onClose:()=>void,
|
onClose:()=>void,
|
||||||
onConfirm:()=>void } = $props();
|
onConfirm:(file:File, idcontrato:string)=>void } = $props();
|
||||||
|
|
||||||
|
let file:File | null = $state(null);
|
||||||
let confirmaGarantes: boolean = $state(false);
|
let confirmaGarantes: boolean = $state(false);
|
||||||
|
|
||||||
|
|
||||||
|
function handleFile(e:Event):void {
|
||||||
|
const input = e.target as HTMLInputElement;
|
||||||
|
if (input.files && input.files.length > 0 ) {
|
||||||
|
file = input.files[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit() {
|
||||||
|
if (file == null) return;
|
||||||
|
onConfirm(file, men.mensaje.split(" ").reverse()[0]);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="modal show d-block" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" style="background-color: rgba(0,0,0,0.5);">
|
<div class="modal show d-block" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" style="background-color: rgba(0,0,0,0.5);">
|
||||||
<div class="modal-dialog modal-xl" role="document">
|
<div class="modal-dialog modal-xl" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -31,29 +45,51 @@
|
|||||||
<th>Domicilio</th>
|
<th>Domicilio</th>
|
||||||
<th>Celular</th>
|
<th>Celular</th>
|
||||||
<th>Domicilio Laboral</th>
|
<th>Domicilio Laboral</th>
|
||||||
<th>Acciones</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each garantes as garante, index}
|
{#each garantes as garante, index}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{index + 1}</td>
|
<td>{index + 1}</td>
|
||||||
<td>{garante.Dni}</td>
|
<td>{garante.dni}</td>
|
||||||
<td>{garante.Nombre}</td>
|
<td>{garante.nombre}</td>
|
||||||
<td>{garante.Apellido}</td>
|
<td>{garante.apellido}</td>
|
||||||
<td>{garante.Domicilio}</td>
|
<td>{garante.domicilio}</td>
|
||||||
<td>{garante.Celular}</td>
|
<td>{garante.celular}</td>
|
||||||
<td>{garante.Domiciliolaboral}</td>
|
<td>{garante.domiciliolaboral}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type="checkbox" bind:checked={confirmaGarantes} disabled={confirmaGarantes}>
|
|
||||||
|
|
||||||
|
<div class="d-flex flex-column align-items-center mt-3">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
id="checkestabien"
|
||||||
|
type="checkbox"
|
||||||
|
class="form-check-input"
|
||||||
|
bind:checked={confirmaGarantes}
|
||||||
|
disabled={confirmaGarantes}
|
||||||
|
>
|
||||||
|
<label for="checkestabien" class="form-check-label ms-2">
|
||||||
|
¿Están bien estos datos?
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{#if confirmaGarantes}
|
||||||
|
<hr>
|
||||||
|
<div class="d-flex flex-column align-items-center mt-3">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="formFile" class="form-label">Suba contrato en pdf</label>
|
||||||
|
<input class="form-control" type="file" id="formFile"
|
||||||
|
onchange={handleFile}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer d-flex justify-content-between">
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
<button class="btn btn-primary" disabled={!confirmaGarantes} onclick={() => onConfirm()} >
|
<button class="btn btn-primary" disabled={!(confirmaGarantes && file != null)} onclick={submit} >
|
||||||
Subir
|
Subir
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-danger" onclick={onCancel}>Cancelar Contrato</button>
|
<button type="button" class="btn btn-danger" onclick={onCancel}>Cancelar Contrato</button>
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
if (mensaje.accion === "Check y Contrato"){
|
if (mensaje.accion === "Check y Contrato"){
|
||||||
Selmens = {...mensaje};
|
Selmens = {...mensaje};
|
||||||
let idcontrato = Number(Selmens.mensaje.split(" ").reverse()[0]);
|
let idcontrato = Number(Selmens.mensaje.split(" ").reverse()[0]);
|
||||||
|
obtenerListaGarantes(idcontrato);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@
|
|||||||
async function obtenerListaGarantes(idcontrato: number) {
|
async function obtenerListaGarantes(idcontrato: number) {
|
||||||
if (Selmens.accion !== "Check y Contrato") return;
|
if (Selmens.accion !== "Check y Contrato") return;
|
||||||
try {
|
try {
|
||||||
const responce = await fetch($urlG+"/api/contratos/precontrato/listaGarantes?idcontrato="+idcontrato+"&EmailPropietario="+sessionStorage.getItem("email"), {
|
const responce = await fetch($urlG+"/api/contratos/precontrato/listaGarantes?idcontrato="+idcontrato+"&EmailPropietario="+localStorage.getItem("email"), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Auth": String(token),
|
"Auth": String(token),
|
||||||
@@ -263,8 +264,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleEnviarmensaje4() {
|
async function handleEnviarmensaje4(file:File, idcontrato:string) {
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("idcontrato", idcontrato);
|
||||||
|
formdata.append("contrato", file);
|
||||||
|
try{
|
||||||
|
const responce = await fetch("", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
},
|
||||||
|
body: formdata,
|
||||||
|
});
|
||||||
|
if () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch{
|
||||||
|
modaldata="Fallo al intentar hacer la request";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user