dev #48
@@ -2,9 +2,8 @@ using AlquilaFacil.Builder;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Modelo;
|
||||
using ZstdSharp.Unsafe;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
@@ -196,12 +195,27 @@ public class ContratoController: ControllerBase {
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/subirContrato")]
|
||||
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm] IFormFile contrato) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
public IActionResult subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato =0, IFormFile contrato) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (idcontrato<=0) return BadRequest(new {message = "No puede tener un id contrato menor o igual a 0"});
|
||||
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
||||
if (contr == null) return BadRequest(new { message = "No hay precontrato por esa id"});
|
||||
|
||||
if (contrato == null) return BadRequest(new { message = "Debe subir un archivo." });
|
||||
if (contrato.ContentType != "application/pdf") return BadRequest(new { message = "El archivo debe ser un documento 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";
|
||||
|
||||
var s3Client = new AmazonS3Client("aVO9C3PqeK1hiPCyqZCj", "szj58kceWG3GcRZ8P1QCQiv5tSjMI7iD5zfjneTT", new AmazonS3Config
|
||||
{
|
||||
ServiceURL = "http://192.168.1.11",
|
||||
ForcePathStyle = true
|
||||
});
|
||||
|
||||
return Ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
6
Entidades/Dto/SubirContratoDto.cs
Normal file
6
Entidades/Dto/SubirContratoDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Entidades.Dto;
|
||||
public class SubirContratoDto{
|
||||
public int IdContrato { get; set; }
|
||||
}
|
||||
@@ -6,12 +6,10 @@
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import { text } from "@sveltejs/kit";
|
||||
import ModalPrecontrato from "../Componentes/ModalPrecontrato.svelte";
|
||||
import { get } from "svelte/store";
|
||||
import ModalAddGarantes from "../Componentes/ModalAddGarantes.svelte";
|
||||
import { Accordion } from "@sveltestrap/sveltestrap";
|
||||
import ModalCheckYContrato from "../Componentes/ModalCheckYContrato.svelte";
|
||||
import { self } from "svelte/legacy";
|
||||
|
||||
const token = sessionStorage.getItem("token");
|
||||
let mensajes: MensajeDto[] = $state([]);
|
||||
@@ -125,6 +123,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerListaGarantes(idcontrato: number) {
|
||||
if (Selmens.accion !== "Check y Contrato") return;
|
||||
try {
|
||||
const responce = await fetch($urlG+"/api/contratos/precontrato/listaGarantes?idcontrato="+idcontrato+"&EmailPropietario="+sessionStorage.getItem("email"), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
},
|
||||
});
|
||||
|
||||
if (responce.ok) {
|
||||
let data = await responce.json();
|
||||
garantes = data;
|
||||
return;
|
||||
}
|
||||
let data = await responce.json();
|
||||
Selmens.accion="";
|
||||
modaldata = data.message;
|
||||
} catch {
|
||||
Selmens.accion="";
|
||||
modaldata="No se pudo Obtener la lista de garantes";
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEnviarmensaje2(data: {opcionVenta:boolean, cantGarantes:number, mesesHastaAumento:number}) {
|
||||
if (data.opcionVenta == null || data.cantGarantes <=0 || data.mesesHastaAumento<=0) {
|
||||
modaldata = "Estan mal cargados los datos del form";
|
||||
@@ -205,8 +227,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleCancelPrecontrato(): void {
|
||||
|
||||
async function handleCancelPrecontrato() {
|
||||
if (Selmens.accion !== "Check y Contrato") return;
|
||||
try {
|
||||
let data = {
|
||||
emailPropietario: Selmens.receptor,
|
||||
emailInquilino: Selmens.remitente,
|
||||
fecha: Selmens.fecha,
|
||||
idpropiedad: Selmens.propiedad,
|
||||
}
|
||||
let responce = await fetch($urlG+"/api/contratos/cancelar", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
if (responce.ok){
|
||||
let dataa = await responce.json();
|
||||
modaldata = dataa.message;
|
||||
if (mostrarleidos) {
|
||||
Leidos();
|
||||
} else {
|
||||
SinLeer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let dataa = await responce.json();
|
||||
modaldata = dataa.message;
|
||||
return
|
||||
}catch {
|
||||
modaldata = "fallo al intentar conectar con el servidor";
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEnviarmensaje4() {
|
||||
|
||||
Reference in New Issue
Block a user