LogicaContratos #40
9
Aspnet/Builder/Builder.cs
Normal file
9
Aspnet/Builder/Builder.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using Minio.Helper;
|
||||||
|
|
||||||
|
public abstract class Builder<T> where T:new() {
|
||||||
|
protected T data = new T();
|
||||||
|
public T Build() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
Aspnet/Builder/DtoBuilder/NotificacionDtoBuilder.cs
Normal file
34
Aspnet/Builder/DtoBuilder/NotificacionDtoBuilder.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
namespace AlquilaFacil.Builder;
|
||||||
|
using Entidades.Dto;
|
||||||
|
public class NotificacionDtoBuilder: Builder<NotificacionDto> {
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetRemitente(string remitente) {
|
||||||
|
data.Remitente = remitente;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetAccion(string accion) {
|
||||||
|
data.Accion = accion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetMensaje(string mensaje) {
|
||||||
|
data.Mensaje = mensaje;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetFecha(DateTime? fecha) {
|
||||||
|
data.Fecha = fecha;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetPropiedad(string propiedad) {
|
||||||
|
data.Propiedad = propiedad;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetReceptor(string receptor) {
|
||||||
|
data.Receptor = receptor;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Aspnet/Builder/GaranteBuilder.cs
Normal file
35
Aspnet/Builder/GaranteBuilder.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Entidades;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Builder;
|
||||||
|
|
||||||
|
public class GaranteBuilder : Builder<Garante> {
|
||||||
|
public GaranteBuilder SetNombre(string Nombre) {
|
||||||
|
data.Nombre = Nombre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteBuilder SetApellido(string Apellido) {
|
||||||
|
data.Apellido = Apellido;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteBuilder SetDni(long Dni) {
|
||||||
|
data.Dni = Dni;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteBuilder SetDomicilio(string Domicilio) {
|
||||||
|
data.Domicilio = Domicilio;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteBuilder SetCelular(string Celular) {
|
||||||
|
data.Celular = Celular;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GaranteBuilder SetDomicilioLaboral(string Domiciliolaboral) {
|
||||||
|
data.Domiciliolaboral = Domiciliolaboral;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Aspnet/Builder/NotificacionBuilder.cs
Normal file
40
Aspnet/Builder/NotificacionBuilder.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using Entidades;
|
||||||
|
|
||||||
|
public class NotificacioneBuilder : Builder<Notificacione>
|
||||||
|
{
|
||||||
|
public NotificacioneBuilder SetDnicliente(long dnicliente) {
|
||||||
|
data.Dnicliente = dnicliente;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetDniremitente(long dniremitente) {
|
||||||
|
data.Dniremitente = dniremitente;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetFecha(DateTime fecha) {
|
||||||
|
data.Fecha = fecha;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetMensaje(string mensaje) {
|
||||||
|
data.Mensaje = mensaje;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetAccion(string accion) {
|
||||||
|
data.Accion = accion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetIdpropiedad(int idpropiedad) {
|
||||||
|
data.Idpropiedad = idpropiedad;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificacioneBuilder SetLeido(bool leido) {
|
||||||
|
data.Leido = leido;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Aspnet/Builder/PrecontratoBuilder.cs
Normal file
45
Aspnet/Builder/PrecontratoBuilder.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
namespace AlquilaFacil.Builder;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Entidades;
|
||||||
|
public class PrecontratoBuilder : Builder<Contrato> {
|
||||||
|
public PrecontratoBuilder SetHabilitado(){
|
||||||
|
data.Habilitado = 0;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetInquilino(long dniInq) {
|
||||||
|
data.Dniinquilino = dniInq;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetPropietario(long dniProp) {
|
||||||
|
data.Dnipropietario = dniProp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetPropiedad(int idprop) {
|
||||||
|
data.Idpropiedad = idprop;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetCantidadGarantes(int cantgarante) {
|
||||||
|
data.Cantgarantemin = cantgarante;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetIndiceActializacionInicial() {
|
||||||
|
data.Indiceactualizacion = 0.000M;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetMesesHastaAumento(int meses) {
|
||||||
|
data.MesesHastaAumento = meses;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrecontratoBuilder SetFecha(DateTime fechaprimernotificacion){
|
||||||
|
data.Fechainicio = fechaprimernotificacion;
|
||||||
|
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; } = "";
|
||||||
|
}
|
||||||
152
Aspnet/Controllers/AdminController.cs
Normal file
152
Aspnet/Controllers/AdminController.cs
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Modelo;
|
||||||
|
using Entidades.Admin;
|
||||||
|
using Entidades.Dto;
|
||||||
|
using Entidades;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using AlquilaFacil.StrategyBusquedaAdmin;
|
||||||
|
using System.Diagnostics;
|
||||||
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
public class AdminController: ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet("api/admin/clientes")]
|
||||||
|
public IActionResult GetClientes([FromHeader(Name ="Auth")]string Auth){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
IEnumerable<UsuarioAdmin>list = RepositorioUsuarios.Singleton.GetClientes();
|
||||||
|
return Ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/admin/clientes/grupo")]
|
||||||
|
public IActionResult GetGruposByCliente([FromHeader(Name ="Auth")]string Auth, [FromQuery]long Dni){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (Dni <= 0) return BadRequest(new {message = "No puede tener un dni con numero negativo o cero"});
|
||||||
|
|
||||||
|
IEnumerable<GrupoAdmin> list = RepositorioGrupos.Singleton.ObtenerGruposPorDni(Dni);
|
||||||
|
return Ok(list);
|
||||||
|
}
|
||||||
|
[HttpPatch("api/admin/cliente/addGrupo")]
|
||||||
|
public IActionResult AddGrupoACliente([FromHeader(Name = "Auth")]string Auth, [FromBody]EmailGrupo data){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (data.email == "" || data.grupo == "") return BadRequest(new { message = "Faltan datos en la request" });
|
||||||
|
|
||||||
|
var ret = RepositorioUsuarios.Singleton.CheckGrupo(data.email, data.grupo);
|
||||||
|
if (ret) return BadRequest(new { message = $"El usuario ya pertenece al grupo {data.grupo}"});
|
||||||
|
|
||||||
|
var ret2 = RepositorioUsuarios.Singleton.AñadirClienteAGrupo(data.email, data.grupo);
|
||||||
|
|
||||||
|
return ret2 ? Ok(new {message = "Se Añadio al Grupo"}): BadRequest(new { message = "Fallo al añadirse al Grupo" });
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPatch("api/admin/cliente/rmGrupo")]
|
||||||
|
public IActionResult RmGrupoACliente([FromHeader(Name = "Auth")]string Auth, [FromBody]EmailGrupo data){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (data.email == "" || data.grupo == "") return BadRequest(new { message = "Faltan datos en la request" });
|
||||||
|
|
||||||
|
//una ward para que no me bloquee a mi mismo de tener acceso a admin
|
||||||
|
if (data.email == "celu@fedesrv.ddns.net" && data.grupo == "Admin") return BadRequest(new { message = "Si hago esto me estaria bloqueando la cuenta a mi mismo" });
|
||||||
|
|
||||||
|
var ret = RepositorioUsuarios.Singleton.CheckGrupo(data.email, data.grupo);
|
||||||
|
if (!ret) return BadRequest(new { message = $"El usuario no pertenece al grupo {data.grupo}"});
|
||||||
|
|
||||||
|
if (data.grupo == "Propietario") {
|
||||||
|
IQueryable<PropiedadesDto> ret3 = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(data.email);
|
||||||
|
if (ret3.Count() > 0){
|
||||||
|
bool ret4 = RepositorioPropiedades.Singleton.BajaPropiedades(data.email);
|
||||||
|
if (ret4 == false) return BadRequest(new { message = "No se pudo dar de baja las propiedades"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.grupo == "Inquilino") {
|
||||||
|
var ret5 = RepositorioContratos.Singleton.ObtenerContratosPorEmailInquilino(data.email);
|
||||||
|
if ( ret5 == null || ret5.Where(x=>x.Habilitado == 0).Count() > 0) return BadRequest(new { message = "Aun tenes alquileres pendientes o fallo al intentar obtener la lista de alquileres, no se puede dar de baja"});
|
||||||
|
}
|
||||||
|
|
||||||
|
var ret2 = RepositorioUsuarios.Singleton.EliminarClienteAGrupo(data.email, data.grupo);
|
||||||
|
return ret2 ? Ok(new {message = $"Se elimino del Grupo: {data.grupo}"}): BadRequest(new { message = "Fallo al añadirse al Grupo" });
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("api/admin/cliente")]
|
||||||
|
public IActionResult BajaCliente([FromHeader(Name ="Auth")]string Auth, long Dni){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if ( Dni <=0) return BadRequest(new {message = "No puede tener un Dni menor o igual a 0"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorDni(Dni);
|
||||||
|
|
||||||
|
if (cli == null) return BadRequest(new {message = "No existe un cliente con ese numero de dni"});
|
||||||
|
|
||||||
|
bool esPropietario = RepositorioUsuarios.Singleton.CheckGrupo(cli.Email, "Propietario");
|
||||||
|
bool esInquilino = RepositorioUsuarios.Singleton.CheckGrupo(cli.Email, "Inquilino");
|
||||||
|
|
||||||
|
if (esPropietario) {
|
||||||
|
IQueryable<PropiedadesDto> ret3 = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(cli.Email);
|
||||||
|
if (ret3.Count() > 0){
|
||||||
|
bool ret4 = RepositorioPropiedades.Singleton.BajaPropiedades(cli.Email);
|
||||||
|
if (ret4 == false) return BadRequest(new { message = "No se pudo dar de baja las propiedades"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (esInquilino) {
|
||||||
|
var ret5 = RepositorioContratos.Singleton.ObtenerContratosPorEmailInquilino(cli.Email);
|
||||||
|
if ( ret5 == null || ret5.Where(x=>x.Habilitado == 0).Count() > 0) return BadRequest(new { message = "Aun tenes alquileres pendientes o fallo al intentar obtener la lista de alquileres, no se puede dar de baja"});
|
||||||
|
}
|
||||||
|
// lo da de baja si no tiene el grupo propietario y no tiene alquileres pendientes
|
||||||
|
var ret = RepositorioUsuarios.Singleton.BajaCliente(Dni);
|
||||||
|
return Ok(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("api/admin/propiedad")]
|
||||||
|
public IActionResult BajaPropiedad([FromHeader(Name = "Auth")] string Auth, int id = 0) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (id <= 0) return BadRequest(new { message = "Falto indicar id Propiedad"});
|
||||||
|
|
||||||
|
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id);
|
||||||
|
return ret ?
|
||||||
|
Ok(new {message = "Se cambio el estado de la propiedad"}): BadRequest(new { message = "No se pudo dar de baja"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/admin/busqueda/paginada")]
|
||||||
|
public IActionResult FiltroPropiedadesPaginado([FromHeader(Name = "Auth")]string Auth, int cantidadHabitaciones = 0, int tipoPropiedad = 0, [FromQuery]string servicios = "", int pag = 1) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
IQueryable<PropiedadesAdmin>? props = null;
|
||||||
|
pag -= 1;
|
||||||
|
|
||||||
|
var clave = $"{(cantidadHabitaciones != 0 ? "1" : "0")}{(tipoPropiedad != 0 ? "1" : "0")}{(!string.IsNullOrEmpty(servicios) ? "1" : "0")}";
|
||||||
|
var gen = AdminBusquedaContext.Singleton;
|
||||||
|
var estrategia = gen.ObtenerEstrategia(clave);
|
||||||
|
props = estrategia.Filtrar(servicios, cantidadHabitaciones, tipoPropiedad, pag);
|
||||||
|
|
||||||
|
return Ok(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/admin/busqueda/cantPag")]
|
||||||
|
public IActionResult CantidadPaginas([FromHeader(Name = "Auth")]string Auth, int cantidadHabitaciones = 0, int tipoPropiedad = 0, [FromQuery]string servicios = "") {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
int ret = RepositorioPropiedades.Singleton.CuantasPaginasBusqueda(cantidadHabitaciones, servicios, tipoPropiedad, 0);
|
||||||
|
return Ok(new { message = ret});
|
||||||
|
}
|
||||||
|
}
|
||||||
38
Aspnet/Controllers/BusquedaControler.cs
Normal file
38
Aspnet/Controllers/BusquedaControler.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using Entidades.Dto;
|
||||||
|
using Modelo;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Entidades.Admin;
|
||||||
|
using AlquilaFacil.StrategyBusqueda;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
public class BusquedaController: ControllerBase {
|
||||||
|
[HttpGet("api/busqueda")]
|
||||||
|
public IActionResult FiltroPropiedades([FromHeader(Name = "Auth")]string Auth, int cantidadHabitaciones = 0, int tipoPropiedad = 0, [FromQuery]string servicios = "") {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 3);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
IQueryable<PropiedadesDto>? props = null;
|
||||||
|
|
||||||
|
var clave = $"{(cantidadHabitaciones != 0 ? "1" : "0")}{(tipoPropiedad != 0 ? "1" : "0")}{(!string.IsNullOrEmpty(servicios) ? "1" : "0")}";
|
||||||
|
|
||||||
|
var gen = BusquedaContext.Singleton;
|
||||||
|
var estrategia = gen.ObtenerEstrategia(clave);
|
||||||
|
props = estrategia.Filtrar(servicios, cantidadHabitaciones, tipoPropiedad);
|
||||||
|
|
||||||
|
return Ok(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/busqueda/cantPag")]
|
||||||
|
public IActionResult GetCantPag([FromHeader(Name = "Auth")]string Auth, int cantidadHabitaciones = 0, int tipoPropiedad = 0, [FromQuery]string servicios = "") {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 3);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
int ret = RepositorioPropiedades.Singleton.CuantasPaginasBusqueda(cantidadHabitaciones, servicios, tipoPropiedad, 1);
|
||||||
|
return Ok(new { message = ret});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
465
Aspnet/Controllers/ContratoController.cs
Normal file
465
Aspnet/Controllers/ContratoController.cs
Normal file
@@ -0,0 +1,465 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
|
using AlquilaFacil.Builder;
|
||||||
|
using AlquilaFacil.Config;
|
||||||
|
using Entidades;
|
||||||
|
using Entidades.Dto;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Minio;
|
||||||
|
using Minio.DataModel;
|
||||||
|
using Minio.DataModel.Args;
|
||||||
|
using Minio.Exceptions;
|
||||||
|
using Modelo;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
public class ContratoController: ControllerBase {
|
||||||
|
|
||||||
|
[HttpGet("api/contratos")] //WIP
|
||||||
|
public IActionResult ObtenerContratosPorUsuario([FromHeader(Name="Auth")]string Auth) {
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/precontrato")]
|
||||||
|
public IActionResult IniciarPrecontrato([FromHeader(Name = "Auth")]string Auth, [FromBody] PrecontratoDto dto) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
string validacion2 = ValidarDtoPrecontrato(dto);
|
||||||
|
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "Tu token no corresponde a ningun cliente (volvete a logear)"});
|
||||||
|
if (cli.Email != dto.EmailPropietario) return BadRequest(new {message = "No Corresponde el email de propietario con el del token"});
|
||||||
|
|
||||||
|
Cliente? propi = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(dto.EmailPropietario);
|
||||||
|
if (propi == null || propi.Dni == 0) return BadRequest(new {message = "No hay propietario por ese email"});
|
||||||
|
|
||||||
|
Cliente? inq = RepositorioInquilinos.Singleton.ObtenerInquilinoPorEmail(dto.EmailInquilino);
|
||||||
|
if (inq == null || inq.Dni == 0) return BadRequest(new {message = "No hay inquilinos por ese email"});
|
||||||
|
|
||||||
|
Propiedade? p = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.IdPropiedad);
|
||||||
|
if (p == null || p.Id == 0) return BadRequest(new {message = "La id de propiedad no corresponde a una propiedad"});
|
||||||
|
|
||||||
|
var precontrato = new PrecontratoBuilder()
|
||||||
|
.SetHabilitado()
|
||||||
|
.SetPropietario(propi.Dni)
|
||||||
|
.SetInquilino(inq.Dni)
|
||||||
|
.SetCantidadGarantes(dto.CantidadGarantes)
|
||||||
|
.SetIndiceActializacionInicial()
|
||||||
|
.SetMesesHastaAumento(dto.MesesHastaAumento)
|
||||||
|
.SetPropiedad(p.Id)
|
||||||
|
.SetFecha(DateTime.Parse(dto.fechaprimernotificacion))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
var notificacion = new NotificacioneBuilder()
|
||||||
|
.SetAccion("Carge Garantes")
|
||||||
|
.SetDniremitente(propi.Dni)
|
||||||
|
.SetDnicliente(inq.Dni)
|
||||||
|
.SetLeido(false)
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.SetIdpropiedad(p.Id)
|
||||||
|
.SetMensaje($"El propietario {propi.Nombre} {propi.Apellido} te requiere que carges informacion de {dto.CantidadGarantes} Garantes")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var ret = RepositorioContratos.Singleton.CargaPrecontrato(precontrato, notificacion);
|
||||||
|
if (ret) {
|
||||||
|
ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, DateTime.Parse(dto.fechaprimernotificacion));
|
||||||
|
}
|
||||||
|
return (ret)?
|
||||||
|
Ok(new {message = "Se Cargo el precontrato y envio una notificacion al inquilino"}):
|
||||||
|
BadRequest(new {message = "No se pudo cargar el precontrato"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("api/contratos/addGarantes")]
|
||||||
|
public IActionResult AddGarantes([FromHeader(Name = "Auth")]string Auth, AltaGarantesDto dto) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
var validacion2 = ValidarDtoAltaGarantes(dto);
|
||||||
|
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "Tu token no corresponde a ningun cliente (volvete a logear)"});
|
||||||
|
if (cli.Email != dto.EmailInquilino) return BadRequest(new {message = "No Corresponde el email de inquilino con el del token"});
|
||||||
|
|
||||||
|
var validacion4 = RepositorioContratos.Singleton.CantidadGarantesEncontrato(dto.EmailInquilino, dto.Idpropiedad);
|
||||||
|
if (validacion4 <= 0 || dto.garantes.Count()!=validacion4) return BadRequest(new{message="Cantidad de garantes incorrecta"});
|
||||||
|
|
||||||
|
Cliente? propi = RepositorioPropietario.Singleton.ObtenerPropietarioPorIdPropiedad(dto.Idpropiedad);
|
||||||
|
if(propi == null) return BadRequest(new{message = "No se encuentra el propietario de la propiedad"});
|
||||||
|
|
||||||
|
foreach (var i in dto.garantes) {
|
||||||
|
string validacion3 = ValidarDtoGarante(i);
|
||||||
|
if (validacion3 != "") return BadRequest( new { message = validacion3 });
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Garante> gar = new();
|
||||||
|
|
||||||
|
foreach (var i in dto.garantes) {
|
||||||
|
Garante g = new GaranteBuilder()
|
||||||
|
.SetNombre(i.Nombre)
|
||||||
|
.SetApellido(i.Apellido)
|
||||||
|
.SetCelular(i.Celular)
|
||||||
|
.SetDomicilio(i.Domicilio)
|
||||||
|
.SetDni(i.Dni)
|
||||||
|
.SetDomicilioLaboral(i.Domiciliolaboral)
|
||||||
|
.Build();
|
||||||
|
gar.Add(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
var contr = RepositorioContratos.Singleton.ObtenerContrato(dto.EmailInquilino, dto.Idpropiedad);
|
||||||
|
if (contr == null) return BadRequest(new { message = "No existe el contrato o ya fue activado"});
|
||||||
|
|
||||||
|
var ret = RepositorioContratos.Singleton.CargaGarantes(gar, dto.EmailInquilino, dto.Idpropiedad);
|
||||||
|
if (ret) {
|
||||||
|
Console.WriteLine(dto.fecha);
|
||||||
|
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.fecha);
|
||||||
|
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetIdpropiedad(dto.Idpropiedad)
|
||||||
|
.SetAccion("Check y Contrato")
|
||||||
|
.SetMensaje($"El inquilino cargó los datos de garantes comprobá y carga el contrato: {contr.Id}")
|
||||||
|
.SetLeido(false)
|
||||||
|
.SetDniremitente(cli.Dni)
|
||||||
|
.SetDnicliente(propi.Dni)
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.Build();
|
||||||
|
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
}
|
||||||
|
return ret ?
|
||||||
|
Ok(new {message = "Se Añadieron los Garantes"}):BadRequest(new { message = "Fallo la carga"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("api/contratos/cancelar")]
|
||||||
|
public IActionResult CancelarPrecontrato([FromHeader(Name = "Auth")]string Auth, CancelarPrecontratoDto dto) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
var validacion2 = ValidarCancelarDto(dto);
|
||||||
|
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
||||||
|
|
||||||
|
Cliente? pro = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(dto.EmailPropietario);
|
||||||
|
if (pro == null) return BadRequest(new {message = "No Existe Usuario con ese email"});
|
||||||
|
if (pro.Token != Auth) return BadRequest(new {message = "El token de auth no corresponde al token el usuario propietario"});
|
||||||
|
|
||||||
|
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.idpropiedad);
|
||||||
|
if (prop == null) return BadRequest(new {message = "No existe la propiedad por esa id"});
|
||||||
|
if (prop.Dnipropietario != pro.Dni) return BadRequest(new {message = "Este propietario no es el dueño de la propiedad"});
|
||||||
|
|
||||||
|
var inq = RepositorioInquilinos.Singleton.ObtenerInquilinoPorEmail(dto.EmailInquilino);
|
||||||
|
if (inq == null) return BadRequest(new {message = "No hay un inquilino por ese email"});
|
||||||
|
|
||||||
|
var ret = RepositorioContratos.Singleton.CancelarPrecontrato(dto.EmailInquilino, dto.idpropiedad);
|
||||||
|
if (ret) {
|
||||||
|
prop.Idestado = 1;
|
||||||
|
ret = RepositorioPropiedades.Singleton.PatchPropiedad(prop);
|
||||||
|
if (ret){
|
||||||
|
RepositorioNotificaciones.Singleton.MarcarComoLeido(pro.Dni, dto.fecha);
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetAccion("ContratoCancelado")
|
||||||
|
.SetIdpropiedad(dto.idpropiedad)
|
||||||
|
.SetDniremitente(pro.Dni)
|
||||||
|
.SetDnicliente(inq.Dni)
|
||||||
|
.SetMensaje($"Se cancelo el intento de alquilar la propiedad: {dto.idpropiedad}")
|
||||||
|
.SetIdpropiedad(dto.idpropiedad)
|
||||||
|
.SetLeido(false)
|
||||||
|
.Build();
|
||||||
|
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
if (ret){
|
||||||
|
return Ok(new {message = "Se cancelo el precontrato"});
|
||||||
|
}else{
|
||||||
|
return Ok(new {message = "Se cancelo el precontrato, pero no se pudo notificar al inquilino"});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return BadRequest(new {message = "No se pudo setear la propiedad como Disponible en busqueda"});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return BadRequest(new {message = "Se fallo al intentar cancelar el precontrato"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/contratos/precontrato/listaGarantes")]
|
||||||
|
public IActionResult ObtenerListaGarantes([FromHeader(Name = "Auth")]string Auth, long idcontrato = 0, [FromQuery] string EmailPropietario = "" ) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (idcontrato == 0 || EmailPropietario == "") return BadRequest(new { message = "Estan mal cargados los datos"});
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "No hay un propietario por ese token"});
|
||||||
|
if (cli.Email != EmailPropietario) return BadRequest(new {message = "El Email del usuario no coinside con el del token"});
|
||||||
|
|
||||||
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
||||||
|
if (contr == null) return BadRequest(new {message = "No hay un precontrato por esa id"});
|
||||||
|
|
||||||
|
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 minioClient) {
|
||||||
|
mc = minioClient;
|
||||||
|
if (mc == null){
|
||||||
|
MinioConfigcus? mcon = JsonSerializer.Deserialize<MinioConfigcus>(System.IO.File.ReadAllText("./settings.json"))?? null;
|
||||||
|
if (mcon == null) throw new Exception();
|
||||||
|
|
||||||
|
mc = new MinioClient().WithCredentials(mcon.usr, mcon.scrt)
|
||||||
|
.WithEndpoint("192.168.1.11:9000")
|
||||||
|
.WithSSL(false)
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/subirContrato")]
|
||||||
|
public async Task<IActionResult> subirContrato([FromHeader(Name = "Auth")]string Auth, [FromForm]long idcontrato, [FromForm]DateTime ubicarnotificacion, IFormFile contrato) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
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 (contr.Dniinquilino == 0 || contr.Dnipropietario == 0 || contr.Idpropiedad == 0 ||
|
||||||
|
contr.Dniinquilino == null || contr.Dnipropietario == null || contr.Idpropiedad == null) {
|
||||||
|
return BadRequest(new { message = "Estan mal cargados los datos del precontrato comunicate con un administrador"});
|
||||||
|
}
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null || contr.DnipropietarioNavigation == null) return BadRequest(new { message ="No se pudo checkear que el token corresponda al propietario"});
|
||||||
|
if (cli.Dni != contr.DnipropietarioNavigation.Dni) return BadRequest(new { message = "el token de usuario no coinside con el usuario propietario"});
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
bool ret = await subirContrato(contrato, nuevoNombreArchivo);
|
||||||
|
if(ret == false) return BadRequest(new {message = "No se pudo subir el archivo"});
|
||||||
|
|
||||||
|
ret = RepositorioContratos.Singleton.AddUrl(contr.Id, nuevoNombreArchivo);
|
||||||
|
if (ret == false) return BadRequest(new { message = "No se pudo guardar la url del contrato" });
|
||||||
|
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetDniremitente(contr.Dnipropietario??0)
|
||||||
|
.SetIdpropiedad(contr.Idpropiedad??0)
|
||||||
|
.SetDnicliente(contr.Dniinquilino??0)
|
||||||
|
.SetAccion("Aceptar Contrato")
|
||||||
|
.SetMensaje($"El propietario: {contr.Dnipropietario}, hizo un documento de contrato: {contr.Id}")
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.SetLeido(false)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, ubicarnotificacion);
|
||||||
|
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
|
||||||
|
return (ret)?
|
||||||
|
Ok(new { message = "se notifico al futuro inquilino"}): BadRequest(new { message = "No se pudo enviar la notificacion"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/contrato/getdocumento")]
|
||||||
|
public IActionResult ObtenerContrato([FromHeader(Name = "Auth")]string Auth, [FromQuery]long idcontrato) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
||||||
|
|
||||||
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(idcontrato);
|
||||||
|
if (contr == null || contr.Dniinquilino == 0) return BadRequest(new { message = "No hay un precontrato por esa id"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||||
|
if (cli.Dni != contr.Dniinquilino) return BadRequest(new { message = "El token no corresponde con el del inquilino"});
|
||||||
|
|
||||||
|
string nuevoNombreArchivo = $"id:{contr.Id}-inq:{contr.Dniinquilino}-propi:{contr.Dnipropietario}-idprop:{contr.Idpropiedad}.pdf";
|
||||||
|
try{
|
||||||
|
var memstream = new MemoryStream();
|
||||||
|
|
||||||
|
var goa = new GetObjectArgs()
|
||||||
|
.WithBucket("alquilafacil")
|
||||||
|
.WithObject(nuevoNombreArchivo)
|
||||||
|
.WithCallbackStream(stream => {
|
||||||
|
memstream.Position=0;
|
||||||
|
stream.CopyTo(memstream);
|
||||||
|
});
|
||||||
|
|
||||||
|
mc.GetObjectAsync(goa).Wait();
|
||||||
|
memstream.Position = 0;
|
||||||
|
|
||||||
|
if (memstream.Length == 0) return BadRequest(new { message = "El archivo está vacío" });
|
||||||
|
|
||||||
|
return File(memstream, "application/pdf", nuevoNombreArchivo);
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
Console.Error.WriteLine(e);
|
||||||
|
return BadRequest(new { message = "Fallo al intentar obtener el archivo del almacenamiento o este no existe"});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/aceptarContrato")]
|
||||||
|
public IActionResult AceptarContrato([FromHeader(Name = "Auth")]string Auth, [FromBody] AceptarContratoDto dto){
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (dto.Idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
||||||
|
|
||||||
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(dto.Idcontrato);
|
||||||
|
if (contr == null || contr.Dniinquilino == 0) return BadRequest(new { message = "No hay un precontrato por esa id"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||||
|
if (cli.Dni != contr.Dniinquilino) return BadRequest(new { message = "El token no corresponde con el del inquilino"});
|
||||||
|
|
||||||
|
bool ret = RepositorioContratos.Singleton.AceptarContrato(dto.Idcontrato);
|
||||||
|
if (ret == false) return BadRequest(new { message ="fallo al aceptar el contrato"});
|
||||||
|
|
||||||
|
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.Fecha);
|
||||||
|
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetDniremitente(cli.Dni)
|
||||||
|
.SetIdpropiedad(contr.Idpropiedad??0)
|
||||||
|
.SetDnicliente(contr.Dnipropietario??0)
|
||||||
|
.SetAccion("Aceptado Contrato")
|
||||||
|
.SetMensaje($"Se inicio el alquiler")
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.SetLeido(false)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
return ret ?
|
||||||
|
Ok(new { message = "Se acepto el contrato y se crearon los Canons a ser pagados"}) :
|
||||||
|
BadRequest(new { message = "No se pudo aceptar el contrato"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("api/contratos/rechazarPreContrato")]
|
||||||
|
public IActionResult CancelarContrato([FromHeader(Name = "Auth")]string Auth, [FromBody] RechazarPreContrato dto ) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (dto.Idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
||||||
|
|
||||||
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerPreContratoPorId(dto.Idcontrato);
|
||||||
|
if (contr == null || contr.Dniinquilino == 0) return BadRequest(new { message = "No hay un precontrato por esa id"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||||
|
if (cli.Dni != contr.Dniinquilino) return BadRequest(new { message = "El token no corresponde con el del inquilino"});
|
||||||
|
|
||||||
|
var ret = RepositorioContratos.Singleton.CancelarPrecontrato(dto.Idcontrato);
|
||||||
|
if (ret == false) return BadRequest(new {message = "Fallo al intentar cancelar el precontrato"});
|
||||||
|
|
||||||
|
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.Fecha);
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetDniremitente(cli.Dni)
|
||||||
|
.SetIdpropiedad(contr.Idpropiedad??0)
|
||||||
|
.SetDnicliente(contr.Dnipropietario??0)
|
||||||
|
.SetAccion("Rechazo Contrato")
|
||||||
|
.SetMensaje($"Se cancelo el proceso para alquilar de: {cli.Nombre}")
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.SetLeido(false)
|
||||||
|
.Build();
|
||||||
|
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
|
||||||
|
return ret?
|
||||||
|
Ok(new { message = "Se cancelo el proceso para iniciar el alquiler"}):
|
||||||
|
BadRequest(new { message = "No se pudo cancelar"});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> subirContrato(IFormFile f, string flname) {
|
||||||
|
try {
|
||||||
|
var buck = new BucketExistsArgs().WithBucket("alquilafacil");
|
||||||
|
bool encontrado = await mc.BucketExistsAsync(buck).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if(!encontrado){
|
||||||
|
var mb = new MakeBucketArgs().WithBucket("alquilafacil");
|
||||||
|
await mc.MakeBucketAsync(mb).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
using (var stream = new MemoryStream()){
|
||||||
|
await f.CopyToAsync(stream);
|
||||||
|
stream.Position=0;
|
||||||
|
PutObjectArgs putbj = new PutObjectArgs()
|
||||||
|
.WithBucket("alquilafacil")
|
||||||
|
.WithObject(flname)
|
||||||
|
.WithStreamData(stream)
|
||||||
|
.WithContentType("application/pdf")
|
||||||
|
.WithObjectSize(stream.Length);
|
||||||
|
await mc.PutObjectAsync(putbj);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e ) {
|
||||||
|
Console.Error.WriteLine(e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ValidarCancelarDto(CancelarPrecontratoDto dto) {
|
||||||
|
if (dto == null) return "dto nulo";
|
||||||
|
string ret = "";
|
||||||
|
|
||||||
|
if (dto.EmailInquilino =="") ret += "No puede tener un EmailInquilino Vacio\n";
|
||||||
|
if (dto.EmailPropietario =="") ret += "No puede tener un EmailPropietario Vacio\n";
|
||||||
|
if (dto.idpropiedad <= 0 ) ret += "No puede tener id propiedad igual o menor a 0\n";
|
||||||
|
if (dto.fecha == DateTime.MinValue) ret += "Falta fecha\n";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ValidarDtoGarante(GaranteDto g) {
|
||||||
|
string ret = "";
|
||||||
|
if (g == null) return "dto nulo";
|
||||||
|
|
||||||
|
if (g.Celular == "") ret += "No puede tener un numero de telefono vacio\n";
|
||||||
|
if (g.Nombre == "") ret += "No puede tener un nombre vacio\n";
|
||||||
|
if (g.Apellido == "") ret += "No puede tener un apellido vacio\n";
|
||||||
|
if (g.Domiciliolaboral == "") ret += "Tiene que especificar su domicilio laboral\n";
|
||||||
|
if (g.Domicilio == "") ret += "Tiene que especificar su domilio\n";
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ValidarDtoAltaGarantes(AltaGarantesDto dto){
|
||||||
|
string ret = "";
|
||||||
|
if (dto == null) return "dto nulo";
|
||||||
|
|
||||||
|
if (dto.garantes.Count()<=0) ret += "No se puede tener 0 o menos garantes\n";
|
||||||
|
if (dto.Idpropiedad<=0) ret += "la id de propiedad no puede ser igual o menor a 0\n";
|
||||||
|
if (dto.EmailInquilino == "") ret += "El email de inquilino no puede estar vacio\n";
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private string ValidarDtoPrecontrato( PrecontratoDto dto) {
|
||||||
|
string ret = "";
|
||||||
|
if (dto == null) return "dto nulo";
|
||||||
|
|
||||||
|
if (dto.CantidadGarantes<0) ret += "la cantidad de garantes necesarios no pueden ser menor a 0\n";
|
||||||
|
if (dto.CantidadGarantes>10) ret += "Hay un maximo de 10 garantes\n";
|
||||||
|
if (dto.EmailInquilino == "") ret += "el email del inquilino no puede ser nulo\n";
|
||||||
|
if (dto.EmailPropietario == "") ret += "el email del propietario no puede estar vacio\n";
|
||||||
|
if (dto.IdPropiedad <= 0) ret += "la id de propiedad no puede ser igual o menor a 0\n";
|
||||||
|
if (dto.MesesHastaAumento <= 0) ret += "No puede tener 0 o menos meses hasta el aumento\n";
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
95
Aspnet/Controllers/NotificacionesController.cs
Normal file
95
Aspnet/Controllers/NotificacionesController.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
using AlquilaFacil.Builder;
|
||||||
|
using Entidades;
|
||||||
|
using Entidades.Dto;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Modelo;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
public class NotificacionesController: ControllerBase {
|
||||||
|
[HttpGet("api/notificaciones")]
|
||||||
|
public IActionResult GetNotificaciones([FromHeader(Name ="Auth")]string Auth, bool leido = false) {
|
||||||
|
if (string.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
|
||||||
|
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "Fallo al intentar encontrar tu usuario (puede que te hayas logeado desde otro dispositivo?)"});
|
||||||
|
|
||||||
|
|
||||||
|
IQueryable<Notificacione> notificaciones = RepositorioNotificaciones.Singleton.ObtenerNotificacionesDeUsuario(cli.Dni)
|
||||||
|
.Where(x=>x.Leido == leido);
|
||||||
|
List<NotificacionDto> noti = new();
|
||||||
|
Parallel.ForEach(notificaciones, i => {
|
||||||
|
var dto = new NotificacionDtoBuilder()
|
||||||
|
.SetRemitente(i.DniremitenteNavigation.Email)
|
||||||
|
.SetAccion(i.Accion)
|
||||||
|
.SetMensaje(i.Mensaje)
|
||||||
|
.SetFecha(i.Fecha)
|
||||||
|
.SetPropiedad(i.IdpropiedadNavigation.Id.ToString())
|
||||||
|
.SetReceptor(i.DniclienteNavigation.Email)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
noti.Add(dto);
|
||||||
|
});
|
||||||
|
return Ok(noti);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/notificaciones/haySinLeer")]
|
||||||
|
public IActionResult GetHayNotis([FromHeader(Name ="Auth")]string Auth) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||||
|
|
||||||
|
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "Fallo al intentar encontrar tu usuario (puede que te hayas logeado desde otro dispositivo?)"});
|
||||||
|
|
||||||
|
bool ret = RepositorioNotificaciones.Singleton.HayNotis(cli.Dni);
|
||||||
|
return Ok(new {message = ret});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("api/notificaciones")]
|
||||||
|
public IActionResult MarcarComoLeido([FromHeader(Name = "Auth")]string Auth, NotificacionMarcarLeidoDto nota) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||||
|
|
||||||
|
if (nota.Fecha == null || String.IsNullOrWhiteSpace(nota.Email)) return BadRequest(new {message = "Faltan datos"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
|
||||||
|
if (cli == null) return BadRequest(new {message = "El token de autorizacion no pertenese a ningun Usuario"});
|
||||||
|
|
||||||
|
if (cli.Email != nota.Email) return BadRequest(new {message = "El token de autorizacion no corresponde a tu usuario"});
|
||||||
|
|
||||||
|
bool ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, nota.Fecha);
|
||||||
|
return ret ?
|
||||||
|
Ok(new{message = "Se Marco como leido"}):BadRequest(new{message = "Fallo al marcarse como leido"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/notificaciones/consultaAlquiler")]
|
||||||
|
public IActionResult ConsultaAlquiler([FromHeader(Name ="Auth")]string Auth, [FromBody] AltaNotificacionDto data) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||||
|
bool validacion1 = RepositorioUsuarios.Singleton.CheckToken(data.Remitente, Auth);
|
||||||
|
if (validacion1 == false) return BadRequest(new {message = "el token no corresponde a su usuario"});
|
||||||
|
|
||||||
|
if (data.Accion == "") return BadRequest(new{message = "El campo Accion esta vacio"});
|
||||||
|
if (data.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||||
|
|
||||||
|
Cliente? inq = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (inq == null) return BadRequest(new { message = "no hay un usuario para el cual el token de autorizacion corresponda (vuelvase a logear)" });
|
||||||
|
|
||||||
|
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(data.Propiedad);
|
||||||
|
if (prop == null || prop.Idestado != 1) return BadRequest(new{message="No hay una propiedad dada de alta para ese id"});
|
||||||
|
if (prop.DnipropietarioNavigation == null) return BadRequest(new{message="la propiedad no tiene propietario dado de alto ????"});
|
||||||
|
|
||||||
|
var noti = new NotificacioneBuilder()
|
||||||
|
.SetAccion(data.Accion)
|
||||||
|
.SetMensaje(data.Mensaje)
|
||||||
|
.SetLeido(false)
|
||||||
|
.SetDnicliente(prop.DnipropietarioNavigation.Dni)
|
||||||
|
.SetDniremitente(inq.Dni)
|
||||||
|
.SetIdpropiedad(prop.Id)
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||||
|
return ret?
|
||||||
|
Ok(new {message = "Se envio la notificacion"}):BadRequest(new {message = "Fallo al intentar guardar la notificacion"});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,19 +8,27 @@ namespace AlquilaFacil.Controllers;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class PropiedadesController: ControllerBase {
|
public class PropiedadesController: ControllerBase {
|
||||||
[HttpGet("api/propiedades")]
|
[HttpGet("api/propiedades")]
|
||||||
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth, int pag = 0) {
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
|
if (validacion1 == false) validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
var ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
IQueryable<PropiedadesDto> ret;
|
||||||
|
|
||||||
|
if (pag == 0){
|
||||||
|
ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||||
|
} else{
|
||||||
|
ret = RepositorioPropiedades.Singleton.ListarPropiedadesPorPagina(pag);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/propiedad")]
|
[HttpGet("api/propiedad")]
|
||||||
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
if (Id < 0) return BadRequest(new {message ="la id de propiedad no puede ser negativa"});
|
if (Id < 0) return BadRequest(new {message ="la id de propiedad no puede ser negativa"});
|
||||||
@@ -30,6 +38,25 @@ public class PropiedadesController: ControllerBase {
|
|||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/propiedad/cantPagina")]
|
||||||
|
public IActionResult ObtenerCantidadDePaginas([FromHeader(Name = "Auth")] string Auth, int estado = 0) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (estado < 0) return BadRequest(new {message = "No puede tener un numero menor a 0"});
|
||||||
|
int cant;
|
||||||
|
|
||||||
|
if(estado == 0){
|
||||||
|
cant = RepositorioPropiedades.Singleton.CuantasPaginas();
|
||||||
|
}else{
|
||||||
|
cant = RepositorioPropiedades.Singleton.CuantasPaginas(estado);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(new {message = cant});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("api/propiedades/Propietario")]
|
[HttpGet("api/propiedades/Propietario")]
|
||||||
public IActionResult ObtenerPropiedadesPorPropietario (
|
public IActionResult ObtenerPropiedadesPorPropietario (
|
||||||
[FromHeader(Name = "Email")] string email,
|
[FromHeader(Name = "Email")] string email,
|
||||||
@@ -81,6 +108,7 @@ public class PropiedadesController: ControllerBase {
|
|||||||
Ubicacion = propiedad.Ubicacion,
|
Ubicacion = propiedad.Ubicacion,
|
||||||
Letra = propiedad.Letra ?? null,
|
Letra = propiedad.Letra ?? null,
|
||||||
Piso = propiedad.Piso ?? null,
|
Piso = propiedad.Piso ?? null,
|
||||||
|
Monto = propiedad.Monto,
|
||||||
};
|
};
|
||||||
|
|
||||||
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop);
|
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop);
|
||||||
@@ -113,6 +141,7 @@ public class PropiedadesController: ControllerBase {
|
|||||||
Letra = propiedad.Letra ?? null,
|
Letra = propiedad.Letra ?? null,
|
||||||
Piso = propiedad.Piso ?? null,
|
Piso = propiedad.Piso ?? null,
|
||||||
IdServicios = servs,
|
IdServicios = servs,
|
||||||
|
Monto = propiedad.Monto
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop);
|
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop);
|
||||||
@@ -191,10 +220,11 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
if (prop.Canthabitaciones < 0) ret += "No se puede tener una cantidad de habitaciones negativa\n";
|
if (prop.Canthabitaciones < 0) ret += "No se puede tener una cantidad de habitaciones negativa\n";
|
||||||
|
|
||||||
if (prop.Idtipropiedad <= 0) ret += "No tiene un tipo de propiedad asociada";
|
if (prop.Idtipropiedad <= 0) ret += "No tiene un tipo de propiedad asociada\n";
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
if (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
||||||
|
|
||||||
|
if (prop.Monto<=1) ret += "El monto tiene que ser como minimo mayor a 0";
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -205,14 +235,15 @@ public class PropiedadesController: ControllerBase {
|
|||||||
if (prop.id <1) ret += "No Cargo el dato de id";
|
if (prop.id <1) ret += "No Cargo el dato de id";
|
||||||
if (String.IsNullOrEmpty(prop.Email)) ret += "Falta Definir un email de propietario\n";
|
if (String.IsNullOrEmpty(prop.Email)) ret += "Falta Definir un email de propietario\n";
|
||||||
|
|
||||||
if (prop.id <1 ) ret += "No puede haber una id menor a 1";
|
if (prop.id <1 ) ret += "No puede haber una id menor a 1\n";
|
||||||
|
|
||||||
if (prop.Canthabitaciones < 0) ret += "No se puede tener una cantidad de habitaciones negativa\n";
|
if (prop.Canthabitaciones < 0) ret += "No se puede tener una cantidad de habitaciones negativa\n";
|
||||||
|
|
||||||
if (prop.tipo <= 0) ret += "No tiene un tipo de propiedad asociada";
|
if (prop.tipo <= 0) ret += "No tiene un tipo de propiedad asociada\n";
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
if (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
||||||
|
|
||||||
|
if (prop.Monto<=1) ret += "El monto tiene que ser como minimo mayor a 0";
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using Minio;
|
||||||
|
using AlquilaFacil.Config;
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
|
||||||
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(options => options
|
||||||
|
.WithCredentials(mcon.usr, mcon.scrt)
|
||||||
|
.WithEndpoint("192.168.1.11:9000")
|
||||||
|
.WithSSL(false)
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
builder.Services.Configure<FormOptions>(options =>
|
||||||
|
{
|
||||||
|
options.MultipartBodyLengthLimit = 50 * 1024 * 1024; // 50 MB
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
|||||||
29
Aspnet/Strategy/Busqueda/BusquedaContext.cs
Normal file
29
Aspnet/Strategy/Busqueda/BusquedaContext.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace AlquilaFacil.StrategyBusqueda;
|
||||||
|
|
||||||
|
public class BusquedaContext
|
||||||
|
{
|
||||||
|
private static readonly BusquedaContext singleton = new();
|
||||||
|
public static BusquedaContext Singleton {get { return singleton; } }
|
||||||
|
|
||||||
|
private readonly Dictionary<string, IBusquedaStrategy> _estrategias;
|
||||||
|
|
||||||
|
public BusquedaContext()
|
||||||
|
{
|
||||||
|
_estrategias = new Dictionary<string, IBusquedaStrategy>
|
||||||
|
{
|
||||||
|
{ "000", new BusquedaSinParametros() },
|
||||||
|
{ "100", new BusquedaPorHabitaciones() },
|
||||||
|
{ "010", new BusquedaPorTipo() },
|
||||||
|
{ "001", new BusquedaPorServicios() },
|
||||||
|
{ "110", new BusquedaPorHabitacionesTipo() },
|
||||||
|
{ "101", new BusquedaPorHabitacionesServicios() },
|
||||||
|
{ "011", new BusquedaTipoServicios() },
|
||||||
|
{ "111", new BusquedaFull() }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBusquedaStrategy ObtenerEstrategia(string clave)
|
||||||
|
{
|
||||||
|
return _estrategias.ContainsKey(clave) ? _estrategias[clave] : new BusquedaSinParametros();
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Aspnet/Strategy/Busqueda/Filtros.cs
Normal file
52
Aspnet/Strategy/Busqueda/Filtros.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Entidades.Dto;
|
||||||
|
using Modelo;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.StrategyBusqueda;
|
||||||
|
|
||||||
|
public class BusquedaSinParametros : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitaciones : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones(cantidadHabitaciones);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorTipo : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorTipo(tipoPropiedad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorServicios : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorServicios(servicios);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitacionesTipo : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_Tipo(cantidadHabitaciones, tipoPropiedad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitacionesServicios : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_Servicios(cantidadHabitaciones, servicios);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaTipoServicios : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorTipo_Servicios(tipoPropiedad, servicios);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaFull : IBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_Tipo_Servicios(cantidadHabitaciones, tipoPropiedad, servicios);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
Aspnet/Strategy/Busqueda/IBusquedaStrategy.cs
Normal file
6
Aspnet/Strategy/Busqueda/IBusquedaStrategy.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AlquilaFacil.StrategyBusqueda;
|
||||||
|
using Entidades.Dto;
|
||||||
|
public interface IBusquedaStrategy {
|
||||||
|
IQueryable<PropiedadesDto> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad);
|
||||||
|
}
|
||||||
|
|
||||||
29
Aspnet/Strategy/BusquedaAdmin/AdminBusquedaContext.cs
Normal file
29
Aspnet/Strategy/BusquedaAdmin/AdminBusquedaContext.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace AlquilaFacil.StrategyBusquedaAdmin;
|
||||||
|
|
||||||
|
public class AdminBusquedaContext
|
||||||
|
{
|
||||||
|
private static readonly AdminBusquedaContext singleton = new();
|
||||||
|
public static AdminBusquedaContext Singleton {get { return singleton; } }
|
||||||
|
|
||||||
|
private readonly Dictionary<string, IAdminBusquedaStrategy> _estrategias;
|
||||||
|
|
||||||
|
public AdminBusquedaContext()
|
||||||
|
{
|
||||||
|
_estrategias = new Dictionary<string, IAdminBusquedaStrategy>
|
||||||
|
{
|
||||||
|
{ "000", new BusquedaSinParametros() },
|
||||||
|
{ "100", new BusquedaPorHabitaciones() },
|
||||||
|
{ "010", new BusquedaPorTipo() },
|
||||||
|
{ "001", new BusquedaPorServicios() },
|
||||||
|
{ "110", new BusquedaPorHabitacionesTipo() },
|
||||||
|
{ "101", new BusquedaPorHabitacionesServicios() },
|
||||||
|
{ "011", new BusquedaTipoServicios() },
|
||||||
|
{ "111", new BusquedaFull() }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAdminBusquedaStrategy ObtenerEstrategia(string clave)
|
||||||
|
{
|
||||||
|
return _estrategias.ContainsKey(clave) ? _estrategias[clave] : new BusquedaSinParametros();
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Aspnet/Strategy/BusquedaAdmin/Filtros.cs
Normal file
52
Aspnet/Strategy/BusquedaAdmin/Filtros.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Entidades.Admin;
|
||||||
|
using Modelo;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.StrategyBusquedaAdmin;
|
||||||
|
|
||||||
|
public class BusquedaSinParametros : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ListarPropiedadesPorPaginaAdmin(pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitaciones : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitacionesPaginado(cantidadHabitaciones, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorTipo : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorTipoPaginado(tipoPropiedad, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorServicios : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorServiciosPaginado(servicios, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitacionesTipo : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_TipoPaginado(cantidadHabitaciones, tipoPropiedad, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaPorHabitacionesServicios : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_Servicios_Paginado(cantidadHabitaciones, servicios, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaTipoServicios : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorTipo_Servicios_Paginado(tipoPropiedad, servicios, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BusquedaFull : IAdminBusquedaStrategy {
|
||||||
|
public IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
return RepositorioPropiedades.Singleton.ObtenerPropiedesPorHabitaciones_Tipo_Servicios_Paginado(cantidadHabitaciones, tipoPropiedad, servicios, pag);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
Aspnet/Strategy/BusquedaAdmin/IAdminBusquedaStrategy.cs
Normal file
6
Aspnet/Strategy/BusquedaAdmin/IAdminBusquedaStrategy.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AlquilaFacil.StrategyBusquedaAdmin;
|
||||||
|
using Entidades.Admin;
|
||||||
|
public interface IAdminBusquedaStrategy {
|
||||||
|
IQueryable<PropiedadesAdmin> Filtrar(string servicios, int cantidadHabitaciones, int tipoPropiedad, int pag);
|
||||||
|
}
|
||||||
|
|
||||||
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"
|
||||||
|
}
|
||||||
4
Aspnet/settings.json
Normal file
4
Aspnet/settings.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usr":"aVO9C3PqeK1hiPCyqZCj",
|
||||||
|
"scrt":"szj58kceWG3GcRZ8P1QCQiv5tSjMI7iD5zfjneTT"
|
||||||
|
}
|
||||||
2
Entidades/Admin/EmailGrupo.cs
Normal file
2
Entidades/Admin/EmailGrupo.cs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
public record EmailGrupo(string email, string grupo);
|
||||||
7
Entidades/Admin/GrupoAdmin.cs
Normal file
7
Entidades/Admin/GrupoAdmin.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
|
||||||
|
public class GrupoAdmin {
|
||||||
|
public int Id {get; set;} = 0;
|
||||||
|
public String Descripcion {get; set;} = "";
|
||||||
|
public List<Entidades.Admin.PermisoAdmin> Permisos {get; set;} = new();
|
||||||
|
}
|
||||||
6
Entidades/Admin/PermisosAdmin.cs
Normal file
6
Entidades/Admin/PermisosAdmin.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
|
||||||
|
public class PermisoAdmin {
|
||||||
|
public int Id {get; set;}
|
||||||
|
public String Descripcion {get; set;} = "";
|
||||||
|
}
|
||||||
12
Entidades/Admin/PropiedadesAdmin.cs
Normal file
12
Entidades/Admin/PropiedadesAdmin.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
public class PropiedadesAdmin {
|
||||||
|
public int id { get; set; }
|
||||||
|
public string Ubicacion { get; set; } = "";
|
||||||
|
public int canthabitaciones { get; set; }
|
||||||
|
public int piso { get; set; }
|
||||||
|
public string letra { get; set; } = "";
|
||||||
|
public string Tipo { get; set; } = "";
|
||||||
|
public string? Servicios {get;set;} = "";
|
||||||
|
public int Monto { get; set; }
|
||||||
|
public string Estado { get; set; } = "";
|
||||||
|
}
|
||||||
8
Entidades/Admin/UsuarioAdmin.cs
Normal file
8
Entidades/Admin/UsuarioAdmin.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
|
||||||
|
public record UsuarioAdmin {
|
||||||
|
public long Dni { get; set; } = 0;
|
||||||
|
public string Nombre { get; set; } = "";
|
||||||
|
public string Email { get; set; } = "";
|
||||||
|
public ulong Habilitado { get; set; }
|
||||||
|
}
|
||||||
@@ -33,6 +33,8 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
|
|
||||||
public virtual DbSet<Grupo> Grupos { get; set; }
|
public virtual DbSet<Grupo> Grupos { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<Notificacione> Notificaciones { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Permiso> Permisos { get; set; }
|
public virtual DbSet<Permiso> Permisos { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Propiedade> Propiedades { get; set; }
|
public virtual DbSet<Propiedade> Propiedades { get; set; }
|
||||||
@@ -154,6 +156,9 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
entity.Property(e => e.Id)
|
entity.Property(e => e.Id)
|
||||||
.HasColumnType("bigint(20)")
|
.HasColumnType("bigint(20)")
|
||||||
.HasColumnName("id");
|
.HasColumnName("id");
|
||||||
|
entity.Property(e => e.Cancelado)
|
||||||
|
.HasColumnType("bit(1)")
|
||||||
|
.HasColumnName("cancelado");
|
||||||
entity.Property(e => e.Cantgarantemin)
|
entity.Property(e => e.Cantgarantemin)
|
||||||
.HasColumnType("int(11)")
|
.HasColumnType("int(11)")
|
||||||
.HasColumnName("cantgarantemin");
|
.HasColumnName("cantgarantemin");
|
||||||
@@ -178,12 +183,16 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
entity.Property(e => e.Indiceactualizacion)
|
entity.Property(e => e.Indiceactualizacion)
|
||||||
.HasPrecision(8)
|
.HasPrecision(8)
|
||||||
.HasColumnName("indiceactualizacion");
|
.HasColumnName("indiceactualizacion");
|
||||||
|
entity.Property(e => e.MesesHastaAumento).HasColumnType("int(11)");
|
||||||
entity.Property(e => e.Monto)
|
entity.Property(e => e.Monto)
|
||||||
.HasPrecision(12)
|
.HasPrecision(12)
|
||||||
.HasColumnName("monto");
|
.HasColumnName("monto");
|
||||||
entity.Property(e => e.Tieneopcionventa)
|
entity.Property(e => e.Tieneopcionventa)
|
||||||
.HasColumnType("bit(1)")
|
.HasColumnType("bit(1)")
|
||||||
.HasColumnName("tieneopcionventa");
|
.HasColumnName("tieneopcionventa");
|
||||||
|
entity.Property(e => e.UrlContrato)
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnName("urlContrato");
|
||||||
|
|
||||||
entity.HasOne(d => d.DniinquilinoNavigation).WithMany(p => p.ContratoDniinquilinoNavigations)
|
entity.HasOne(d => d.DniinquilinoNavigation).WithMany(p => p.ContratoDniinquilinoNavigations)
|
||||||
.HasForeignKey(d => d.Dniinquilino)
|
.HasForeignKey(d => d.Dniinquilino)
|
||||||
@@ -312,17 +321,20 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
|
|
||||||
modelBuilder.Entity<Garante>(entity =>
|
modelBuilder.Entity<Garante>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasKey(e => e.Dni).HasName("PRIMARY");
|
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
||||||
|
|
||||||
entity.Property(e => e.Dni)
|
entity.Property(e => e.Id)
|
||||||
.HasColumnType("bigint(20)")
|
.HasColumnType("int(11)")
|
||||||
.HasColumnName("dni");
|
.HasColumnName("id");
|
||||||
entity.Property(e => e.Apellido)
|
entity.Property(e => e.Apellido)
|
||||||
.HasMaxLength(20)
|
.HasMaxLength(20)
|
||||||
.HasColumnName("apellido");
|
.HasColumnName("apellido");
|
||||||
entity.Property(e => e.Celular)
|
entity.Property(e => e.Celular)
|
||||||
.HasMaxLength(40)
|
.HasMaxLength(40)
|
||||||
.HasColumnName("celular");
|
.HasColumnName("celular");
|
||||||
|
entity.Property(e => e.Dni)
|
||||||
|
.HasColumnType("bigint(20)")
|
||||||
|
.HasColumnName("dni");
|
||||||
entity.Property(e => e.Domicilio)
|
entity.Property(e => e.Domicilio)
|
||||||
.HasMaxLength(40)
|
.HasMaxLength(40)
|
||||||
.HasColumnName("domicilio");
|
.HasColumnName("domicilio");
|
||||||
@@ -333,7 +345,7 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
.HasMaxLength(20)
|
.HasMaxLength(20)
|
||||||
.HasColumnName("nombre");
|
.HasColumnName("nombre");
|
||||||
|
|
||||||
entity.HasMany(d => d.Idcontratos).WithMany(p => p.Dnigarantes)
|
entity.HasMany(d => d.Idcontratos).WithMany(p => p.Idgarantes)
|
||||||
.UsingEntity<Dictionary<string, object>>(
|
.UsingEntity<Dictionary<string, object>>(
|
||||||
"ContratoGarante",
|
"ContratoGarante",
|
||||||
r => r.HasOne<Contrato>().WithMany()
|
r => r.HasOne<Contrato>().WithMany()
|
||||||
@@ -341,17 +353,17 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
.OnDelete(DeleteBehavior.Restrict)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.HasConstraintName("FK_CONGAR_CON"),
|
.HasConstraintName("FK_CONGAR_CON"),
|
||||||
l => l.HasOne<Garante>().WithMany()
|
l => l.HasOne<Garante>().WithMany()
|
||||||
.HasForeignKey("Dnigarante")
|
.HasForeignKey("Idgarante")
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.HasConstraintName("FK_CONGAR_GAR"),
|
.HasConstraintName("FK_CONGAR_GAR"),
|
||||||
j =>
|
j =>
|
||||||
{
|
{
|
||||||
j.HasKey("Dnigarante", "Idcontrato").HasName("PRIMARY");
|
j.HasKey("Idgarante", "Idcontrato").HasName("PRIMARY");
|
||||||
j.ToTable("contrato_garantes");
|
j.ToTable("contrato_garantes");
|
||||||
j.HasIndex(new[] { "Idcontrato" }, "FK_CONGAR_CON");
|
j.HasIndex(new[] { "Idcontrato" }, "FK_CONGAR_CON");
|
||||||
j.IndexerProperty<long>("Dnigarante")
|
j.IndexerProperty<int>("Idgarante")
|
||||||
.HasColumnType("bigint(20)")
|
.HasColumnType("int(11)")
|
||||||
.HasColumnName("dnigarante");
|
.HasColumnName("idgarante");
|
||||||
j.IndexerProperty<long>("Idcontrato")
|
j.IndexerProperty<long>("Idcontrato")
|
||||||
.HasColumnType("bigint(20)")
|
.HasColumnType("bigint(20)")
|
||||||
.HasColumnName("idcontrato");
|
.HasColumnName("idcontrato");
|
||||||
@@ -370,6 +382,50 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
.HasColumnName("nombre");
|
.HasColumnName("nombre");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Notificacione>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => new { e.Dnicliente, e.Fecha }).HasName("PRIMARY");
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Idpropiedad, "FK_NOTPROP");
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Dniremitente, "FK_NOTREM");
|
||||||
|
|
||||||
|
entity.Property(e => e.Dnicliente)
|
||||||
|
.HasColumnType("bigint(20)")
|
||||||
|
.HasColumnName("dnicliente");
|
||||||
|
entity.Property(e => e.Fecha)
|
||||||
|
.HasColumnType("datetime")
|
||||||
|
.HasColumnName("fecha");
|
||||||
|
entity.Property(e => e.Accion)
|
||||||
|
.HasMaxLength(30)
|
||||||
|
.HasColumnName("accion");
|
||||||
|
entity.Property(e => e.Dniremitente)
|
||||||
|
.HasColumnType("bigint(20)")
|
||||||
|
.HasColumnName("dniremitente");
|
||||||
|
entity.Property(e => e.Idpropiedad)
|
||||||
|
.HasColumnType("int(11)")
|
||||||
|
.HasColumnName("idpropiedad");
|
||||||
|
entity.Property(e => e.Leido).HasColumnName("leido");
|
||||||
|
entity.Property(e => e.Mensaje)
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnName("mensaje");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.DniclienteNavigation).WithMany(p => p.NotificacioneDniclienteNavigations)
|
||||||
|
.HasForeignKey(d => d.Dnicliente)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.HasConstraintName("FK_NOTCLI");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.DniremitenteNavigation).WithMany(p => p.NotificacioneDniremitenteNavigations)
|
||||||
|
.HasForeignKey(d => d.Dniremitente)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.HasConstraintName("FK_NOTREM");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdpropiedadNavigation).WithMany(p => p.Notificaciones)
|
||||||
|
.HasForeignKey(d => d.Idpropiedad)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.HasConstraintName("FK_NOTPROP");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<Permiso>(entity =>
|
modelBuilder.Entity<Permiso>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
||||||
@@ -378,7 +434,7 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
.HasColumnType("int(11)")
|
.HasColumnType("int(11)")
|
||||||
.HasColumnName("id");
|
.HasColumnName("id");
|
||||||
entity.Property(e => e.Descripcion)
|
entity.Property(e => e.Descripcion)
|
||||||
.HasMaxLength(15)
|
.HasMaxLength(25)
|
||||||
.HasColumnName("descripcion");
|
.HasColumnName("descripcion");
|
||||||
|
|
||||||
entity.HasMany(d => d.Idgrupos).WithMany(p => p.Idpermisos)
|
entity.HasMany(d => d.Idgrupos).WithMany(p => p.Idpermisos)
|
||||||
@@ -435,6 +491,9 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
.HasMaxLength(1)
|
.HasMaxLength(1)
|
||||||
.IsFixedLength()
|
.IsFixedLength()
|
||||||
.HasColumnName("letra");
|
.HasColumnName("letra");
|
||||||
|
entity.Property(e => e.Monto)
|
||||||
|
.HasPrecision(10)
|
||||||
|
.HasColumnName("monto");
|
||||||
entity.Property(e => e.Piso)
|
entity.Property(e => e.Piso)
|
||||||
.HasColumnType("int(11)")
|
.HasColumnType("int(11)")
|
||||||
.HasColumnName("piso");
|
.HasColumnName("piso");
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ public partial class Cliente
|
|||||||
|
|
||||||
public virtual ICollection<Contrato> ContratoDnipropietarioNavigations { get; set; } = new List<Contrato>();
|
public virtual ICollection<Contrato> ContratoDnipropietarioNavigations { get; set; } = new List<Contrato>();
|
||||||
|
|
||||||
|
public virtual ICollection<Notificacione> NotificacioneDniclienteNavigations { get; set; } = new List<Notificacione>();
|
||||||
|
|
||||||
|
public virtual ICollection<Notificacione> NotificacioneDniremitenteNavigations { get; set; } = new List<Notificacione>();
|
||||||
|
|
||||||
public virtual ICollection<Propiedade> Propiedades { get; set; } = new List<Propiedade>();
|
public virtual ICollection<Propiedade> Propiedades { get; set; } = new List<Propiedade>();
|
||||||
|
|
||||||
public virtual ICollection<Venta> VentaIdCompradorNavigations { get; set; } = new List<Venta>();
|
public virtual ICollection<Venta> VentaIdCompradorNavigations { get; set; } = new List<Venta>();
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ public partial class Contrato
|
|||||||
|
|
||||||
public ulong Habilitado { get; set; }
|
public ulong Habilitado { get; set; }
|
||||||
|
|
||||||
|
public int MesesHastaAumento { get; set; }
|
||||||
|
|
||||||
|
public string? UrlContrato { get; set; }
|
||||||
|
|
||||||
|
public ulong Cancelado { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Defecto> Defectos { get; set; } = new List<Defecto>();
|
public virtual ICollection<Defecto> Defectos { get; set; } = new List<Defecto>();
|
||||||
|
|
||||||
public virtual Cliente? DniinquilinoNavigation { get; set; }
|
public virtual Cliente? DniinquilinoNavigation { get; set; }
|
||||||
@@ -37,7 +43,7 @@ public partial class Contrato
|
|||||||
|
|
||||||
public virtual Venta? IdventaNavigation { get; set; }
|
public virtual Venta? IdventaNavigation { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Garante> Dnigarantes { get; set; } = new List<Garante>();
|
|
||||||
|
|
||||||
public virtual ICollection<Canon> Idcanons { get; set; } = new List<Canon>();
|
public virtual ICollection<Canon> Idcanons { get; set; } = new List<Canon>();
|
||||||
|
|
||||||
|
public virtual ICollection<Garante> Idgarantes { get; set; } = new List<Garante>();
|
||||||
}
|
}
|
||||||
|
|||||||
5
Entidades/Dto/AceptarContratoDto.cs
Normal file
5
Entidades/Dto/AceptarContratoDto.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class AceptarContratoDto {
|
||||||
|
public long Idcontrato { get; set; }
|
||||||
|
public DateTime Fecha { get; set; }
|
||||||
|
}
|
||||||
9
Entidades/Dto/AltaGarantesDto.cs
Normal file
9
Entidades/Dto/AltaGarantesDto.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
|
||||||
|
public class AltaGarantesDto {
|
||||||
|
public string EmailInquilino { get; set; } = "";
|
||||||
|
public int Idpropiedad {get; set;}
|
||||||
|
public DateTime fecha { get; set;}
|
||||||
|
public List<GaranteDto> garantes{ get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
7
Entidades/Dto/AltaNotificacionDto.cs
Normal file
7
Entidades/Dto/AltaNotificacionDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class AltaNotificacionDto {
|
||||||
|
public string Remitente { get; set; } ="";
|
||||||
|
public string Accion { get; set; } ="";
|
||||||
|
public string Mensaje { get; set; } ="";
|
||||||
|
public int Propiedad { get; set;}
|
||||||
|
}
|
||||||
@@ -6,4 +6,5 @@ public class AltaPropiedadDto {
|
|||||||
public string? Letra { get; set; } = null;
|
public string? Letra { get; set; } = null;
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
public int Idtipropiedad { get; set; }
|
public int Idtipropiedad { get; set; }
|
||||||
|
public int Monto { get; set; }
|
||||||
}
|
}
|
||||||
3
Entidades/Dto/BusquedaDto.cs
Normal file
3
Entidades/Dto/BusquedaDto.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
|
||||||
|
public record BusquedaDto(int Id, string Ubicacion, string? Servicios = "");
|
||||||
8
Entidades/Dto/CancelarPrecontratoDto.cs
Normal file
8
Entidades/Dto/CancelarPrecontratoDto.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class CancelarPrecontratoDto {
|
||||||
|
public string EmailPropietario { get; set; } ="";
|
||||||
|
public string EmailInquilino { get; set; } ="";
|
||||||
|
public DateTime fecha { get; set; }
|
||||||
|
|
||||||
|
public int idpropiedad { get; set; } = 0;
|
||||||
|
}
|
||||||
16
Entidades/Dto/GaranteDto.cs
Normal file
16
Entidades/Dto/GaranteDto.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
|
||||||
|
public class GaranteDto {
|
||||||
|
public long Dni { get; set; }
|
||||||
|
|
||||||
|
public string Nombre { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Apellido { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Domicilio { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Celular { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Domiciliolaboral { get; set; } = null!;
|
||||||
|
|
||||||
|
}
|
||||||
9
Entidades/Dto/NotificacionDto.cs
Normal file
9
Entidades/Dto/NotificacionDto.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class NotificacionDto {
|
||||||
|
public string Remitente { get; set; } ="";
|
||||||
|
public string Accion { get; set; } ="";
|
||||||
|
public string Receptor { get; set; } ="";
|
||||||
|
public string Mensaje { get; set; } ="";
|
||||||
|
public DateTime? Fecha{get; set;} =null;
|
||||||
|
public string Propiedad { get; set;} ="";
|
||||||
|
}
|
||||||
1
Entidades/Dto/NotificacionMarcarLeidoDto.cs
Normal file
1
Entidades/Dto/NotificacionMarcarLeidoDto.cs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
public record NotificacionMarcarLeidoDto(DateTime? Fecha, string Email);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Entidades.Dto;
|
namespace Entidades.Dto;
|
||||||
|
|
||||||
public record PatchPropiedadDto(int id, string Ubicacion, int Canthabitaciones, int? Piso, string? Letra, string Email, int tipo, List<string> Servicios);
|
public record PatchPropiedadDto(int id, string Ubicacion, int Canthabitaciones, int? Piso, string? Letra, string Email, int tipo, List<string> Servicios, int Monto);
|
||||||
|
|||||||
10
Entidades/Dto/PrecontratoDto.cs
Normal file
10
Entidades/Dto/PrecontratoDto.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class PrecontratoDto {
|
||||||
|
public string EmailInquilino { get; set; } = "";
|
||||||
|
public string EmailPropietario { get; set; } = "";
|
||||||
|
public int IdPropiedad { get; set; }
|
||||||
|
public int CantidadGarantes { get; set; }
|
||||||
|
public int MesesHastaAumento { get; set; }
|
||||||
|
public bool TieneOpcionVenta { get; set; }
|
||||||
|
public string fechaprimernotificacion { get; set; }
|
||||||
|
}
|
||||||
@@ -7,4 +7,5 @@ public class PropiedadesDto {
|
|||||||
public string letra { get; set; } = "";
|
public string letra { get; set; } = "";
|
||||||
public string Tipo { get; set; } = "";
|
public string Tipo { get; set; } = "";
|
||||||
public string? Servicios {get;set;} = "";
|
public string? Servicios {get;set;} = "";
|
||||||
|
public int Monto { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
5
Entidades/Dto/RechazarContratoDto.cs
Normal file
5
Entidades/Dto/RechazarContratoDto.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class RechazarPreContrato {
|
||||||
|
public long Idcontrato { get; set; }
|
||||||
|
public DateTime Fecha { get; set; }
|
||||||
|
}
|
||||||
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; }
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ namespace Entidades;
|
|||||||
|
|
||||||
public partial class Garante
|
public partial class Garante
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
public long Dni { get; set; }
|
public long Dni { get; set; }
|
||||||
|
|
||||||
public string Nombre { get; set; } = null!;
|
public string Nombre { get; set; } = null!;
|
||||||
|
|||||||
27
Entidades/Notificacione.cs
Normal file
27
Entidades/Notificacione.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Entidades;
|
||||||
|
|
||||||
|
public partial class Notificacione
|
||||||
|
{
|
||||||
|
public long Dnicliente { get; set; }
|
||||||
|
|
||||||
|
public long Dniremitente { get; set; }
|
||||||
|
|
||||||
|
public DateTime Fecha { get; set; }
|
||||||
|
|
||||||
|
public string Mensaje { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Accion { get; set; } = null!;
|
||||||
|
|
||||||
|
public int Idpropiedad { get; set; }
|
||||||
|
|
||||||
|
public bool Leido { get; set; }
|
||||||
|
|
||||||
|
public virtual Cliente DniclienteNavigation { get; set; } = null!;
|
||||||
|
|
||||||
|
public virtual Cliente DniremitenteNavigation { get; set; } = null!;
|
||||||
|
|
||||||
|
public virtual Propiedade IdpropiedadNavigation { get; set; } = null!;
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ public partial class Propiedade
|
|||||||
|
|
||||||
public int? Idestado { get; set; }
|
public int? Idestado { get; set; }
|
||||||
|
|
||||||
|
public decimal Monto { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Contrato> Contratos { get; set; } = new List<Contrato>();
|
public virtual ICollection<Contrato> Contratos { get; set; } = new List<Contrato>();
|
||||||
|
|
||||||
public virtual Cliente? DnipropietarioNavigation { get; set; }
|
public virtual Cliente? DnipropietarioNavigation { get; set; }
|
||||||
@@ -29,6 +31,8 @@ public partial class Propiedade
|
|||||||
|
|
||||||
public virtual TipoPropiedad IdtipropiedadNavigation { get; set; } = null!;
|
public virtual TipoPropiedad IdtipropiedadNavigation { get; set; } = null!;
|
||||||
|
|
||||||
|
public virtual ICollection<Notificacione> Notificaciones { get; set; } = new List<Notificacione>();
|
||||||
|
|
||||||
public virtual ICollection<Venta> Venta { get; set; } = new List<Venta>();
|
public virtual ICollection<Venta> Venta { get; set; } = new List<Venta>();
|
||||||
|
|
||||||
public virtual ICollection<Servicio> IdServicios { get; set; } = new List<Servicio>();
|
public virtual ICollection<Servicio> IdServicios { get; set; } = new List<Servicio>();
|
||||||
|
|||||||
BIN
Front/bun.lockb
BIN
Front/bun.lockb
Binary file not shown.
@@ -5,7 +5,11 @@
|
|||||||
<link rel="icon" type="image/png" href="/favicon.svg" />
|
<link rel="icon" type="image/png" href="/favicon.svg" />
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"/>
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"/>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>
|
||||||
|
// Configura el tema desde localStorage antes de cargar la aplicación
|
||||||
|
const savedTheme = localStorage.getItem("theme") || "light";
|
||||||
|
document.documentElement.setAttribute("data-bs-theme", savedTheme);
|
||||||
|
</script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>AlquilaFacil</title>
|
<title>AlquilaFacil</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/kit": "^2.7.3",
|
"@sveltejs/kit": "^2.7.3",
|
||||||
"@sveltestrap/sveltestrap": "^6.2.7",
|
"@sveltestrap/sveltestrap": "^6.2.7",
|
||||||
|
"chartjs": "^0.3.24",
|
||||||
"svelte-routing": "^2.13.0"
|
"svelte-routing": "^2.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
Front/public/bell.svg
Normal file
1
Front/public/bell.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-bell"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6" /><path d="M9 17v1a3 3 0 0 0 6 0v-1" /></svg>
|
||||||
|
After Width: | Height: | Size: 447 B |
14
Front/public/toggle-left.svg
Normal file
14
Front/public/toggle-left.svg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!--
|
||||||
|
unicode: "fec0"
|
||||||
|
version: "3.2"
|
||||||
|
-->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M8 9a3 3 0 1 1 -3 3l.005 -.176a3 3 0 0 1 2.995 -2.824" />
|
||||||
|
<path d="M16 5a7 7 0 0 1 0 14h-8a7 7 0 0 1 0 -14zm0 2h-8a5 5 0 1 0 0 10h8a5 5 0 0 0 0 -10" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 327 B |
14
Front/public/toggle-right.svg
Normal file
14
Front/public/toggle-right.svg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!--
|
||||||
|
unicode: "febf"
|
||||||
|
version: "3.2"
|
||||||
|
-->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M16 9a3 3 0 1 1 -3 3l.005 -.176a3 3 0 0 1 2.995 -2.824" />
|
||||||
|
<path d="M16 5a7 7 0 0 1 0 14h-8a7 7 0 0 1 0 -14zm0 2h-8a5 5 0 1 0 0 10h8a5 5 0 0 0 0 -10" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 328 B |
19
Front/public/zoom.svg
Normal file
19
Front/public/zoom.svg
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!--
|
||||||
|
tags: [find, magnifier, magnifying glass]
|
||||||
|
version: "1.0"
|
||||||
|
unicode: "fdaa"
|
||||||
|
-->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="white"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" />
|
||||||
|
<path d="M21 21l-6 -6" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 369 B |
@@ -13,6 +13,10 @@
|
|||||||
import FrontInquilino from "./paginas/grupos/InquilinoG.svelte";
|
import FrontInquilino from "./paginas/grupos/InquilinoG.svelte";
|
||||||
import FrontPropietario from "./paginas/grupos/PropietarioG.svelte";
|
import FrontPropietario from "./paginas/grupos/PropietarioG.svelte";
|
||||||
import PublicarPropiedad from "./paginas/PublicarPropiedad.svelte";
|
import PublicarPropiedad from "./paginas/PublicarPropiedad.svelte";
|
||||||
|
import BusquedaPropiedades from "./paginas/BusquedaPropiedades.svelte";
|
||||||
|
import AdminUsuarios from "./paginas/AdminUsuarios.svelte";
|
||||||
|
import AdminPropiedades from "./paginas/AdminPropiedades.svelte";
|
||||||
|
import Notificaciones from "./paginas/Notificaciones.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Router>
|
<Router>
|
||||||
@@ -30,7 +34,8 @@
|
|||||||
<ProteRoute componente={MenuPage} />
|
<ProteRoute componente={MenuPage} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<!--Publicar Propiedad-->
|
<!--Publicar Prop
|
||||||
|
iedad-->
|
||||||
<Route path="/accion/1">
|
<Route path="/accion/1">
|
||||||
<ProteRoute componente={PublicarPropiedad}/>
|
<ProteRoute componente={PublicarPropiedad}/>
|
||||||
</Route>
|
</Route>
|
||||||
@@ -40,22 +45,38 @@
|
|||||||
<ProteRoute componente={MisPropiedades}/>
|
<ProteRoute componente={MisPropiedades}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!--Buscar Propiedades-->
|
||||||
|
<Route path="/accion/3">
|
||||||
|
<ProteRoute componente={BusquedaPropiedades}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
<!--Crear Cuenta Inquilino-->
|
<!--Crear Cuenta Inquilino-->
|
||||||
<Route path="/accion/4">
|
<Route path="/accion/4">
|
||||||
<ProteRoute componente={InqPage}/>
|
<ProteRoute componente={InqPage}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|
||||||
<!--Crear Cuenta Propietario-->
|
<!--Crear Cuenta Propietario-->
|
||||||
<Route path="/accion/5">
|
<Route path="/accion/5">
|
||||||
<ProteRoute componente={PropPage}/>
|
<ProteRoute componente={PropPage}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<!--Crear Cuenta Propietario-->
|
<!--Administrar Propiedades Dadas de Baja-->
|
||||||
<Route path="/accion/8">
|
<Route path="/accion/8">
|
||||||
<ProteRoute componente={MisPropiedadesDeBaja}/>
|
<ProteRoute componente={MisPropiedadesDeBaja}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!-- Pantalla Control Usuarios -->
|
||||||
|
<Route path="/accion/9">
|
||||||
|
<ProteRoute componente={AdminUsuarios}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
<!-- Pantalla Control Propiedades -->
|
||||||
|
<Route path="/accion/10">
|
||||||
|
<ProteRoute componente={AdminPropiedades}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Paginas info Grupo-->
|
<!--Paginas info Grupo-->
|
||||||
<Route path="/grupo/Inquilino">
|
<Route path="/grupo/Inquilino">
|
||||||
<ProteRoute componente={FrontInquilino}/>
|
<ProteRoute componente={FrontInquilino}/>
|
||||||
@@ -70,6 +91,10 @@
|
|||||||
<ProteRoute componente={FrontInformes}/>
|
<ProteRoute componente={FrontInformes}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!--Notificaciones-->
|
||||||
|
<Route path="/notificaciones">
|
||||||
|
<ProteRoute componente={Notificaciones}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
86
Front/src/Componentes/AdminPanelBusqueda.svelte
Normal file
86
Front/src/Componentes/AdminPanelBusqueda.svelte
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import "./css/dotted-line.css";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import type { AdminParametrosBusqueda, PropiedadAdmin } from "../types";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
|
let canthabitaciones:number = $state(0);
|
||||||
|
let servicios = ["Gas", "Internet", "Telefono", "Luz"];
|
||||||
|
let serviciosSel:string[] = $state([]);
|
||||||
|
let tipo: number = $state(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let { Params }: { Params: (a: AdminParametrosBusqueda) => void} = $props();
|
||||||
|
|
||||||
|
let token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
async function formsubmit(e: Event){
|
||||||
|
e.preventDefault();
|
||||||
|
let params: AdminParametrosBusqueda = {
|
||||||
|
cantidadhabitaciones: canthabitaciones||0,
|
||||||
|
pag: 1,
|
||||||
|
servicios: serviciosSel.join(","),
|
||||||
|
tipopropiedad: tipo,
|
||||||
|
};
|
||||||
|
Params(params);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form class="card p-3 border border-succes">
|
||||||
|
|
||||||
|
<div>Busqueda Filtrada
|
||||||
|
<div class="dotted-line"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="canthabitaciones"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={canthabitaciones}
|
||||||
|
min="0"
|
||||||
|
placeholder="Cantidad de Habitaciones"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<h6 class="form-floating form-label">Servicios</h6>
|
||||||
|
{#each servicios as servicio}
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="form-check-input"
|
||||||
|
bind:group={serviciosSel}
|
||||||
|
value={servicio}
|
||||||
|
id={`servicio-${servicio}`}
|
||||||
|
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for={`servicio-${servicio}`}>
|
||||||
|
{servicio}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<select id="idtipo" class="form-select" bind:value={tipo} required>
|
||||||
|
<option value="0">No Define</option>
|
||||||
|
<option value="1">Casa</option>
|
||||||
|
<option value="2">Piso</option>
|
||||||
|
<option value="3">Departamento</option>
|
||||||
|
<option value="4">Galpon</option>
|
||||||
|
<option value="5">LocalComercial</option>
|
||||||
|
<option value="6">Oficina</option>
|
||||||
|
</select>
|
||||||
|
<label for="idtipopropiedad">Tipo de propiedad</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary w-100 d-flex align-items-center justify-content-center" onclick={formsubmit}>
|
||||||
|
Buscar
|
||||||
|
<img src="/zoom.svg" alt="" class="ms-2" style="height: 1.2em;" />
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
59
Front/src/Componentes/AdminPropiedad.svelte
Normal file
59
Front/src/Componentes/AdminPropiedad.svelte
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PropiedadAdmin } from "../types";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
|
||||||
|
let { prop, modal }: { prop: PropiedadAdmin, modal: (a:string) => void } = $props();
|
||||||
|
|
||||||
|
const token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
async function cambioEstado() {
|
||||||
|
try {
|
||||||
|
const response = await fetch($urlG+"/api/admin/propiedad?id="+prop.id, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
prop.estado = prop.estado=="Baja" ? "Disponible": "Baja";
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = await response.json();
|
||||||
|
modal(String(data.message));
|
||||||
|
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
modal("Fallo al intentar enviar la peticion para dar de baja");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="card text-center border shadow-sm">
|
||||||
|
<div class="card-header bg-primary text-white">
|
||||||
|
<h5 class="mb-0">{prop.tipo}</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="card-img-top mb-3">
|
||||||
|
<i class="bi bi-building" style="font-size: 3rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h6 class="card-title">{prop.ubicacion}</h6>
|
||||||
|
<p class="card-text">
|
||||||
|
<strong>Habitaciones:</strong> {prop.canthabitaciones}<br>
|
||||||
|
<strong>Piso:</strong> {prop.piso || "N/A"}<br>
|
||||||
|
<strong>Letra:</strong> {prop.letra || "N/A"}<br>
|
||||||
|
<strong>Servicios:</strong> {prop.servicios || "Sin servicios especificados"}<br>
|
||||||
|
<strong>Monto:</strong> ${prop.monto}<br>
|
||||||
|
<strong>Estado:</strong> {prop.estado}<br>
|
||||||
|
</p>
|
||||||
|
{#if prop.estado == "Disponible"}
|
||||||
|
<button class="btn btn-success" onclick={cambioEstado}>Baja</button>
|
||||||
|
{:else}
|
||||||
|
<button class="btn btn-danger" onclick={cambioEstado}>Alta</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-muted">
|
||||||
|
ID Propiedad: {prop.id}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let prop = $props();
|
let {text} = $props();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col"><hr></div>
|
<div class="col"><hr></div>
|
||||||
<div class="col-auto"><h5>{prop.text}</h5></div>
|
<div class="col-auto"><h5>{text}</h5></div>
|
||||||
<div class="col"><hr></div>
|
<div class="col"><hr></div>
|
||||||
</div>
|
</div>
|
||||||
14
Front/src/Componentes/BotonVolverArriba.svelte
Normal file
14
Front/src/Componentes/BotonVolverArriba.svelte
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
const scrollToTop = () => {
|
||||||
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="btn btn-primary position-fixed bottom-0 end-0 mb-4 me-4 p-3"
|
||||||
|
on:click={scrollToTop}
|
||||||
|
title="Ir arriba"
|
||||||
|
style="z-index: 1000; "
|
||||||
|
>
|
||||||
|
↑
|
||||||
|
</button>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import { links, navigate } from "svelte-routing";
|
||||||
|
|
||||||
type Permiso = {
|
type Permiso = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -21,7 +23,7 @@
|
|||||||
const match = path.match(/\/grupo\/(.+)/);
|
const match = path.match(/\/grupo\/(.+)/);
|
||||||
const grupo = match ? match[1] : null;
|
const grupo = match ? match[1] : null;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/acciones/grupo",{
|
const response = await fetch(String($urlG)+"/api/acciones/grupo",{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth' : String(token),
|
'Auth' : String(token),
|
||||||
@@ -37,11 +39,14 @@
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function redirijir(path: string){
|
||||||
|
navigate(path);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="list-group" style="border: 1px solid black">
|
<div class="list-group border border-success" use:links>
|
||||||
{#each $permisos as item}
|
{#each $permisos as item}
|
||||||
<a href="/accion/{item.id}" class="list-group-item list-group-item-action">
|
<a class="list-group-item list-group-item-action" href="/accion/{item.id}">
|
||||||
{item.descripcion}
|
{item.descripcion}
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { CardHeader, CardTitle, Button, Card, Input, Form, CardBody, FormGroup } from '@sveltestrap/sveltestrap';
|
import { CardHeader, CardTitle, Button, Card, Input, Form, CardBody, FormGroup } from '@sveltestrap/sveltestrap';
|
||||||
import { navigate } from 'svelte-routing';
|
import { navigate } from 'svelte-routing';
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let email = $state("")
|
let email = $state("")
|
||||||
let contraseña = $state("")
|
let contraseña = $state("")
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
|
|
||||||
const data = {email, contraseña};
|
const data = {email, contraseña};
|
||||||
try{
|
try{
|
||||||
const response = await fetch("http://127.0.0.1:5007/api/login",{
|
const response = await fetch(String($urlG)+"/api/login",{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ret = await response.json();
|
const ret = await response.json();
|
||||||
localStorage.clear();
|
|
||||||
localStorage.setItem('email', ret.email);
|
localStorage.setItem('email', ret.email);
|
||||||
sessionStorage.setItem('token', ret.token);
|
sessionStorage.setItem('token', ret.token);
|
||||||
//setTimeout(() => console.log("50ms") ,50);
|
//setTimeout(() => console.log("50ms") ,50);
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="position-sticky top-50 start-50 translate-middle-x" style="width: 20rem; height: auto;" theme="auto" color="dark" outline>
|
<Card class="position-sticky top-50 start-50 translate-middle-x border border-success" style="width: 20rem; height: auto;" theme="auto" outline>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Iniciar Sesión</CardTitle>
|
<CardTitle>Iniciar Sesión</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
165
Front/src/Componentes/ModalAddGarantes.svelte
Normal file
165
Front/src/Componentes/ModalAddGarantes.svelte
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { GaranteDto } from "../types";
|
||||||
|
|
||||||
|
let { onClose, onSubmit, maxGarantes }: {
|
||||||
|
onClose: () => void,
|
||||||
|
onSubmit: (garantes: GaranteDto[]) => void,
|
||||||
|
maxGarantes: number
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let cantGarantes: number = $state(0);
|
||||||
|
let garantes: GaranteDto[] = $state([]);
|
||||||
|
let showAddForm: boolean = $state(false);
|
||||||
|
|
||||||
|
// Nuevo garante temporal para el formulario.
|
||||||
|
let newGarante: GaranteDto = $state({
|
||||||
|
Dni: 0,
|
||||||
|
Nombre: "",
|
||||||
|
Apellido: "",
|
||||||
|
Domicilio: "",
|
||||||
|
Celular: "",
|
||||||
|
Domiciliolaboral: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleSubmit(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSubmit(garantes);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addGarante() {
|
||||||
|
if (cantGarantes < maxGarantes) {
|
||||||
|
garantes = [...garantes, { ...newGarante }];
|
||||||
|
cantGarantes = garantes.length;
|
||||||
|
resetNewGarante();
|
||||||
|
showAddForm = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetNewGarante() {
|
||||||
|
newGarante = {
|
||||||
|
Dni: 0,
|
||||||
|
Nombre: "",
|
||||||
|
Apellido: "",
|
||||||
|
Domicilio: "",
|
||||||
|
Celular: "",
|
||||||
|
Domiciliolaboral: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Nuevo Alquiler - Garantes</h5>
|
||||||
|
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form onsubmit={handleSubmit}>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<p>Garantes añadidos: {cantGarantes}/{maxGarantes}</p>
|
||||||
|
<button
|
||||||
|
class="btn btn-success"
|
||||||
|
type="button"
|
||||||
|
onclick={() => (showAddForm = true)}
|
||||||
|
disabled={cantGarantes >= maxGarantes}
|
||||||
|
>
|
||||||
|
Añadir Garante
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Formulario para añadir un garante -->
|
||||||
|
{#if showAddForm}
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<h6>Añadir Garante</h6>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>DNI</label>
|
||||||
|
<input type="number" class="form-control" bind:value={newGarante.Dni} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Nombre</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Nombre} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Apellido</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Apellido} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Domicilio</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Domicilio} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Celular</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Celular} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Domicilio Laboral</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Domiciliolaboral} required />
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<button
|
||||||
|
class="btn btn-secondary"
|
||||||
|
type="button"
|
||||||
|
onclick={() => (showAddForm = false)}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary" type="button" onclick={addGarante}>
|
||||||
|
Confirmar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Tabla de garantes -->
|
||||||
|
{#if cantGarantes > 0}
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<label>Lista de Garantes</label>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>DNI</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Apellido</th>
|
||||||
|
<th>Domicilio</th>
|
||||||
|
<th>Celular</th>
|
||||||
|
<th>Domicilio Laboral</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each garantes as garante, index}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="number" class="form-control" bind:value={garantes[index].Dni} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Nombre} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Apellido} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Domicilio} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Celular} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Domiciliolaboral} required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
|
<button type="button" class="btn btn-secondary" onclick={onClose}>Cancelar</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Confirmar</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
107
Front/src/Componentes/ModalCheckYContrato.svelte
Normal file
107
Front/src/Componentes/ModalCheckYContrato.svelte
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { GaranteDto, MensajeDto } from "../types";
|
||||||
|
|
||||||
|
let {men, garantes , onCancel, onConfirm, onClose
|
||||||
|
} : {
|
||||||
|
men: MensajeDto,
|
||||||
|
garantes: GaranteDto[],
|
||||||
|
onCancel:()=>void,
|
||||||
|
onClose:()=>void,
|
||||||
|
onConfirm:(file:File, idcontrato:string)=>void } = $props();
|
||||||
|
|
||||||
|
let file:File | null = $state(null);
|
||||||
|
let confirmaGarantes: boolean = $state(false);
|
||||||
|
let clickeado: 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;
|
||||||
|
clickeado = true;
|
||||||
|
onConfirm(file, men.mensaje.split(" ").reverse()[0]);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
</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-dialog modal-xl" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="staticModalLabel">Lista de Garantes y subir Contrato</h5>
|
||||||
|
<button type="button" class="btn-close" aria-label="Close" onclick={onClose}></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>DNI</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Apellido</th>
|
||||||
|
<th>Domicilio</th>
|
||||||
|
<th>Celular</th>
|
||||||
|
<th>Domicilio Laboral</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each garantes as garante, index}
|
||||||
|
<tr>
|
||||||
|
<td>{index + 1}</td>
|
||||||
|
<td>{garante.dni}</td>
|
||||||
|
<td>{garante.nombre}</td>
|
||||||
|
<td>{garante.apellido}</td>
|
||||||
|
<td>{garante.domicilio}</td>
|
||||||
|
<td>{garante.celular}</td>
|
||||||
|
<td>{garante.domiciliolaboral}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<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 class="modal-footer d-flex justify-content-between">
|
||||||
|
<button class="btn btn-primary" disabled={!(confirmaGarantes && file != null && clickeado == false)} onclick={submit} >
|
||||||
|
{#if clickeado == false}
|
||||||
|
Subir
|
||||||
|
{:else}
|
||||||
|
<div class="spinner-border" role="status">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-danger" onclick={onCancel}>Cancelar Contrato</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
36
Front/src/Componentes/ModalConfirm.svelte
Normal file
36
Front/src/Componentes/ModalConfirm.svelte
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let {show = false, title = "Confirmación",
|
||||||
|
message = "¿Está seguro?",
|
||||||
|
onConfirm , onCancel
|
||||||
|
}:{
|
||||||
|
show:boolean, title: string, message: string, onConfirm:()=>void, onCancel:()=>void } = $props();
|
||||||
|
|
||||||
|
function handleConfirm() {
|
||||||
|
onConfirm();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCancel() {
|
||||||
|
onCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if show}
|
||||||
|
<div class="modal fade show d-block" tabindex="-1" style="background-color: rgba(0,0,0,0.5);">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">{title}</h5>
|
||||||
|
<button type="button" class="btn-close" aria-label="Close" onclick={handleCancel}></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>{message}</p>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<button class="btn btn-secondary" onclick={handleCancel}>Cancelar</button>
|
||||||
|
<button class="btn btn-primary" onclick={handleConfirm}>Aceptar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
50
Front/src/Componentes/ModalPrecontrato.svelte
Normal file
50
Front/src/Componentes/ModalPrecontrato.svelte
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let { onClose, onSubmit } : {
|
||||||
|
onClose: () => void,
|
||||||
|
onSubmit: (data: { opcionVenta: boolean; cantGarantes: number; mesesHastaAumento: number }) => void
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let opcionVenta: boolean = $state(false);
|
||||||
|
let cantGarantes: number = $state(0);
|
||||||
|
let mesesHastaAumento: number = $state(0);
|
||||||
|
|
||||||
|
function handleSubmit(e:Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSubmit({ opcionVenta, cantGarantes, mesesHastaAumento });
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Nuevo Alquiler</h5>
|
||||||
|
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form onsubmit={handleSubmit}>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" bind:checked={opcionVenta} id="opcionVenta" />
|
||||||
|
<label class="form-check-label" for="opcionVenta">Seleccionar Opcion de Venta</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="cantGarantes">Cantidad de Garantes</label>
|
||||||
|
<input type="number" class="form-control" id="cantGarantes" bind:value={cantGarantes} min="0" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="mesesHastaAumento">Meses Hasta Aumento</label>
|
||||||
|
<input type="number" class="form-control" id="mesesHastaAumento" bind:value={mesesHastaAumento} min="0" required />
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
|
<button type="button" class="btn btn-secondary" onclick={onClose}>Cancelar</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Confirmar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
95
Front/src/Componentes/ModalVeryAceptarContrato.svelte
Normal file
95
Front/src/Componentes/ModalVeryAceptarContrato.svelte
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { MensajeDto } from "../types";
|
||||||
|
|
||||||
|
let {getContrato, onConfirm, onCancel, onClose, men
|
||||||
|
} : {
|
||||||
|
getContrato:(idcontrato:number)=>void,
|
||||||
|
onConfirm:(idcontrato:number)=>void,
|
||||||
|
onCancel:(idcontrato:number)=>void,
|
||||||
|
onClose:()=>void,
|
||||||
|
men: MensajeDto
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let contratoDescargado = $state(false);
|
||||||
|
let leiContrato:boolean = $state(false);
|
||||||
|
|
||||||
|
function descargarContrato() {
|
||||||
|
let idcontrato = Number(men.mensaje.split(" ").reverse()[0]);
|
||||||
|
getContrato(idcontrato);
|
||||||
|
contratoDescargado = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmar() {
|
||||||
|
if (leiContrato) {
|
||||||
|
let idcontrato = Number(men.mensaje.split(" ").reverse()[0]);
|
||||||
|
onConfirm(idcontrato);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function rechazar() {
|
||||||
|
if (leiContrato) {
|
||||||
|
let idcontrato = Number(men.mensaje.split(" ").reverse()[0]);
|
||||||
|
onCancel(idcontrato);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="modal show d-block" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Contrato</h5>
|
||||||
|
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Por favor, descargue y lea el contrato antes de aceptar o rechazar.</p>
|
||||||
|
<div class="d-flex flex-column align-items-center">
|
||||||
|
<button class="btn btn-primary mb-3" onclick={descargarContrato}>
|
||||||
|
Descargar contrato
|
||||||
|
</button>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="leiContratoCheckbox"
|
||||||
|
bind:checked={leiContrato}
|
||||||
|
disabled={!contratoDescargado}
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="leiContratoCheckbox">
|
||||||
|
Firme el contrato con el agente de la inmobiliaria
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
|
<button
|
||||||
|
class="btn btn-success"
|
||||||
|
onclick={confirmar}
|
||||||
|
disabled={!leiContrato}
|
||||||
|
>
|
||||||
|
Aceptar
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-danger"
|
||||||
|
onclick={rechazar}
|
||||||
|
disabled={!leiContrato}
|
||||||
|
>
|
||||||
|
Rechazar
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-secondary" onclick={onClose}>
|
||||||
|
Cerrar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal {
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Fondo semi-transparente */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,9 +2,15 @@
|
|||||||
import { Navbar, NavbarBrand, NavbarToggler, Nav, Collapse } from "@sveltestrap/sveltestrap";
|
import { Navbar, NavbarBrand, NavbarToggler, Nav, Collapse } from "@sveltestrap/sveltestrap";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
import { link, links } from "svelte-routing";
|
||||||
import './css/popup.css';
|
import './css/popup.css';
|
||||||
import type { Grupo } from "../types";
|
import type { Grupo } from "../types";
|
||||||
|
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import { navigate } from "svelte-routing";
|
||||||
|
|
||||||
let isOpen: boolean = $state(false);
|
let isOpen: boolean = $state(false);
|
||||||
|
let hayNotis:boolean = $state(false);
|
||||||
|
|
||||||
const permisos = writable<Grupo[]>([]);
|
const permisos = writable<Grupo[]>([]);
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
@@ -12,7 +18,7 @@
|
|||||||
|
|
||||||
async function obtenerPermisos(){
|
async function obtenerPermisos(){
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/acciones",{
|
const response = await fetch(String($urlG)+"/api/acciones",{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth' : String(token),
|
'Auth' : String(token),
|
||||||
@@ -33,26 +39,72 @@
|
|||||||
|
|
||||||
onMount( () => {
|
onMount( () => {
|
||||||
obtenerPermisos();
|
obtenerPermisos();
|
||||||
|
obtenerNotis();
|
||||||
})
|
})
|
||||||
|
|
||||||
function redirijir(path: string){
|
async function obtenerNotis() {
|
||||||
location.replace(path);
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones/haySinLeer", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
hayNotis = data.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirijir(path: string){
|
||||||
|
navigate(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
let theme = $state(localStorage.getItem("theme") ?? "light");
|
||||||
|
const toggleTheme = () => {
|
||||||
|
theme = theme === "light" ? "dark" : "light";
|
||||||
|
document.body.setAttribute("data-bs-theme", theme);
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar container="xxl" expand="md" color="dark-subtle">
|
<Navbar container="xxl" expand="md" color="dark-subtle">
|
||||||
<NavbarBrand href="/">
|
<NavbarBrand href="/">
|
||||||
AlquilaFacil
|
AlquilaFacil
|
||||||
</NavbarBrand>
|
</NavbarBrand>
|
||||||
<div class="badge">
|
<div>
|
||||||
<a href="/Menu">
|
<div class="badge" style="background-color: turquoise;" use:links>
|
||||||
<img src="/home.svg" alt="Volver al Menú"/>
|
<a href="/Menu">
|
||||||
</a>
|
<img src="/home.svg" alt="Volver al Menú"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<button class="badge btn" onclick={toggleTheme} style="background-color: cadetblue;">
|
||||||
|
{#if theme === "light" }
|
||||||
|
<img src="/toggle-left.svg" alt=""/>
|
||||||
|
{:else}
|
||||||
|
<img src="/toggle-right.svg" alt=""/>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
<button class="badge btn btn-info position-relative" onclick={()=>navigate("/notificaciones")}>
|
||||||
|
<img src="/bell.svg" alt="">
|
||||||
|
{#if hayNotis}
|
||||||
|
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
|
||||||
|
!
|
||||||
|
<span class="visually-hidden">unread messages</span>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||||
<Collapse isOpen={isOpen} navbar expand="md">
|
<Collapse isOpen={isOpen} navbar expand="md">
|
||||||
<Nav class="ms-auto" navbar>
|
<Nav class="ms-auto" navbar >
|
||||||
{#each $permisos as item }
|
{#each $permisos as item }
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<div class="btn-group" style="margin-left: 3px; margin-top: 3px">
|
<div class="btn-group" style="margin-left: 3px; margin-top: 3px">
|
||||||
@@ -60,9 +112,9 @@
|
|||||||
<button class="btn btn-secondary dropdown-toggle dropdown-toggle-split" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="btn btn-secondary dropdown-toggle dropdown-toggle-split" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
<span class="visually-hidden">Toggle Dropdown</span>
|
<span class="visually-hidden">Toggle Dropdown</span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-end" >
|
<ul class="dropdown-menu dropdown-menu-end" use:links>
|
||||||
{#each item.idpermisos as perm}
|
{#each item.idpermisos as perm}
|
||||||
<a class="dropdown-item link-underline-opacity-0 link-underline" href="/accion/{perm.id}">{perm.descripcion}</a>
|
<a class="dropdown-item link-underline-opacity-0 link-underline" href="/accion/{perm.id}" >{perm.descripcion}</a>
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -2,7 +2,12 @@
|
|||||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
||||||
|
|
||||||
let isOpen:boolean = false;
|
let isOpen:boolean = false;
|
||||||
|
let theme = $state(localStorage.getItem("theme") ?? "light");
|
||||||
|
const toggleTheme = () => {
|
||||||
|
theme = theme === "light" ? "dark" : "light";
|
||||||
|
document.body.setAttribute("data-bs-theme", theme);
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@@ -10,6 +15,15 @@
|
|||||||
<NavbarBrand href="/">
|
<NavbarBrand href="/">
|
||||||
AlquilaFacil
|
AlquilaFacil
|
||||||
</NavbarBrand>
|
</NavbarBrand>
|
||||||
|
<div>
|
||||||
|
<button class="badge btn" onclick={toggleTheme} style="background-color: cadetblue;">
|
||||||
|
{#if theme === "light" }
|
||||||
|
<img src="/toggle-left.svg" alt=""/>
|
||||||
|
{:else}
|
||||||
|
<img src="/toggle-right.svg" alt=""/>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||||
<Collapse isOpen={isOpen} navbar expand="md">
|
<Collapse isOpen={isOpen} navbar expand="md">
|
||||||
<Nav class="ms-auto" navbar>
|
<Nav class="ms-auto" navbar>
|
||||||
|
|||||||
35
Front/src/Componentes/PaginacionStepper.svelte
Normal file
35
Front/src/Componentes/PaginacionStepper.svelte
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
|
||||||
|
let {currentPag,
|
||||||
|
cantpag,
|
||||||
|
queryPag
|
||||||
|
}:{
|
||||||
|
currentPag: number,
|
||||||
|
cantpag: number,
|
||||||
|
queryPag: (a:number) => void} = $props();
|
||||||
|
|
||||||
|
|
||||||
|
const token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
let array = $derived.by(()=> Array.from({ length: cantpag }, (_, i) => i + 1));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if cantpag>1}
|
||||||
|
<nav aria-label="Page navigation example">
|
||||||
|
<ul class="pagination">
|
||||||
|
{#each array as num }
|
||||||
|
{#if currentPag !== num}
|
||||||
|
<li class="page-item"><a class="page-link" href="#" onclick={()=>queryPag(num)}>{String(num)}</a></li>
|
||||||
|
{:else}
|
||||||
|
<li class="page-item"><a class="page-link active" href="#" onclick={()=>queryPag(num)}>{String(num)}</a></li>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{/if}
|
||||||
75
Front/src/Componentes/PanelBusqueda.svelte
Normal file
75
Front/src/Componentes/PanelBusqueda.svelte
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
|
||||||
|
import "./css/dotted-line.css";
|
||||||
|
import { navigate } from 'svelte-routing';
|
||||||
|
|
||||||
|
let canthabitaciones = $state(0);
|
||||||
|
let servicios = ["Gas", "Internet", "Telefono", "Luz"];
|
||||||
|
let serviciosSel = $state([]);
|
||||||
|
let tipo = $state(0);
|
||||||
|
|
||||||
|
async function formsubmit (e:Event){
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const url = window.location.pathname;
|
||||||
|
|
||||||
|
const goto = url+"?cantidadHabitaciones="+canthabitaciones+"&tipoPropiedad="+tipo+"&servicios="+serviciosSel.join(",");
|
||||||
|
window.location.replace(goto);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form class="card p-3 border border-succes">
|
||||||
|
|
||||||
|
<div>Busqueda Filtrada
|
||||||
|
<div class="dotted-line"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="canthabitaciones"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={canthabitaciones}
|
||||||
|
min="1"
|
||||||
|
placeholder="Cantidad de Habitaciones"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<h6 class="form-floating form-label">Servicios</h6>
|
||||||
|
{#each servicios as servicio}
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="form-check-input"
|
||||||
|
bind:group={serviciosSel}
|
||||||
|
value={servicio}
|
||||||
|
id={`servicio-${servicio}`}
|
||||||
|
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for={`servicio-${servicio}`}>
|
||||||
|
{servicio}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<select id="idtipo" class="form-select" bind:value={tipo} required>
|
||||||
|
<option value="1">Casa</option>
|
||||||
|
<option value="2">Piso</option>
|
||||||
|
<option value="3">Departamento</option>
|
||||||
|
<option value="4">Galpon</option>
|
||||||
|
<option value="5">LocalComercial</option>
|
||||||
|
<option value="6">Oficina</option>
|
||||||
|
</select>
|
||||||
|
<label for="idtipopropiedad">Tipo de propiedad</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary w-100 d-flex align-items-center justify-content-center" onclick={formsubmit}>
|
||||||
|
Buscar
|
||||||
|
<img src="/zoom.svg" alt="" class="ms-2" style="height: 1.2em;" />
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
78
Front/src/Componentes/PublicacionPropiedad.svelte
Normal file
78
Front/src/Componentes/PublicacionPropiedad.svelte
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PropiedadDto } from "../types";
|
||||||
|
import ModalConfirm from "./ModalConfirm.svelte";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import ModalEstatico from "./ModalEstatico.svelte";
|
||||||
|
|
||||||
|
let { prop }: { prop: PropiedadDto } = $props();
|
||||||
|
|
||||||
|
let show: boolean = $state(false);
|
||||||
|
let token = sessionStorage.getItem("token");
|
||||||
|
let remitente = localStorage.getItem("email");
|
||||||
|
const accion = "Nuevo Alquiler";
|
||||||
|
let modaldata = $state("");
|
||||||
|
let mensaje = `Alquiler: ${prop.ubicacion} a ${remitente}`;
|
||||||
|
|
||||||
|
const message: string = "Queres consultar con el propietario por el alquiler? (esto le envia una notificacion y email al propietario)";
|
||||||
|
|
||||||
|
|
||||||
|
function Consultar() {
|
||||||
|
show = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onConfirm() {
|
||||||
|
const propiedad = prop.id;
|
||||||
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones/consultaAlquiler", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body : JSON.stringify({remitente, accion, mensaje, propiedad})
|
||||||
|
});
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
show=!show;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancel() {
|
||||||
|
show=!show;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
|
<ModalConfirm {show} {message} title="Consulta" {onConfirm} {onCancel}/>
|
||||||
|
<div class="card text-center border shadow-sm">
|
||||||
|
<div class="card-header bg-primary text-white">
|
||||||
|
<h5 class="mb-0">{prop.tipo}</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="card-img-top mb-3">
|
||||||
|
<i class="bi bi-building" style="font-size: 3rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h6 class="card-title">{prop.ubicacion}</h6>
|
||||||
|
<p class="card-text">
|
||||||
|
<strong>Habitaciones:</strong> {prop.canthabitaciones}<br>
|
||||||
|
<strong>Piso:</strong> {prop.piso || "N/A"}<br>
|
||||||
|
<strong>Letra:</strong> {prop.letra || "N/A"}<br>
|
||||||
|
<strong>Servicios:</strong> {prop.servicios || "Sin servicios especificados"}<br>
|
||||||
|
<strong>Monto:</strong> ${prop.monto}<br>
|
||||||
|
</p>
|
||||||
|
<button class="btn btn-primary" onclick={Consultar}>Alquilar</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-muted">
|
||||||
|
ID Propiedad: {prop.id}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
import ModalEstatico from "./ModalEstatico.svelte";
|
import ModalEstatico from "./ModalEstatico.svelte";
|
||||||
import ModificarPropiedadForm from "./modificarPropiedadForm.svelte";
|
import ModificarPropiedadForm from "./modificarPropiedadForm.svelte";
|
||||||
|
|
||||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja", monto } = $props();
|
||||||
|
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let modal: boolean = $state(false);
|
let modal: boolean = $state(false);
|
||||||
let modalpayload: string = $state("");
|
let modalpayload: string = $state("");
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
async function BajaPropiedad(){
|
async function BajaPropiedad(){
|
||||||
modal = false;
|
modal = false;
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
const responce = await fetch(String($urlG)+"/api/propiedad?id="+id, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers:{
|
headers:{
|
||||||
'Auth' : String(sessionStorage.getItem("token")),
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
@@ -28,7 +30,7 @@
|
|||||||
const json = await responce.json();
|
const json = await responce.json();
|
||||||
modalpayload = json.message;
|
modalpayload = json.message;
|
||||||
modal = true;
|
modal = true;
|
||||||
location.reload();
|
window.location.reload();
|
||||||
}catch (e){
|
}catch (e){
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
@@ -43,9 +45,9 @@
|
|||||||
<td>{piso}</td>
|
<td>{piso}</td>
|
||||||
<td>{tipo}</td>
|
<td>{tipo}</td>
|
||||||
<td>{servicios}</td>
|
<td>{servicios}</td>
|
||||||
|
<td>{monto}</td>
|
||||||
<td class="text-end">
|
<td class="text-end">
|
||||||
<button class="btn btn-outline-secondary" onclick={()=> setmod()}>Modificar</button>
|
<button class="btn btn-outline-secondary" onclick={()=> setmod()}>Modificar</button>
|
||||||
<button class="btn btn-outline-secondary" >Ver Más</button>
|
|
||||||
<button class="btn btn-outline-danger" onclick={() => BajaPropiedad()}>{btnbaja}</button>
|
<button class="btn btn-outline-danger" onclick={() => BajaPropiedad()}>{btnbaja}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
{#if modificar}
|
{#if modificar}
|
||||||
<tr transition:fade={{duration:100}}>
|
<tr transition:fade={{duration:100}}>
|
||||||
<td colspan="8">
|
<td colspan="8">
|
||||||
<ModificarPropiedadForm {id} {ubicacion} {canthabitaciones} {letra} {piso} {tipo} {servicios}/>
|
<ModificarPropiedadForm {id} {ubicacion} {canthabitaciones} {letra} {piso} {tipo} {servicios} {monto}/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,54 +1,55 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { navigate } from 'svelte-routing';
|
import { writable } from 'svelte/store';
|
||||||
import { writable } from 'svelte/store';
|
|
||||||
|
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let { componente } = $props();
|
let { componente } = $props();
|
||||||
|
|
||||||
const isAuthenticated = writable(false);
|
const isAuthenticated = writable(false);
|
||||||
const isVerified = writable(false);
|
const isVerified = writable(false);
|
||||||
|
|
||||||
const redirect = window.location.pathname;
|
const redirect = window.location.pathname;
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
const token = sessionStorage.getItem('token');
|
const token = sessionStorage.getItem('token');
|
||||||
|
|
||||||
const handleAccess = async () => {
|
const handleAccess = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://127.0.0.1:5007/api/login/validar', {
|
const response = await fetch($urlG+"/api/login/validar", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ email, redirect }),
|
body: JSON.stringify({ email, redirect }),
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
isAuthenticated.set(true); // Actualiza el store
|
isAuthenticated.set(true); // Actualiza el store
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error durante la autenticación:', error);
|
|
||||||
} finally {
|
|
||||||
isVerified.set(true); // Marca la verificación como completada
|
|
||||||
}
|
}
|
||||||
};
|
} catch (error) {
|
||||||
|
console.error('Error durante la autenticación:', error);
|
||||||
|
} finally {
|
||||||
|
isVerified.set(true); // Marca la verificación como completada
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
handleAccess();
|
handleAccess();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !$isVerified}
|
{#if !$isVerified}
|
||||||
<div class="spinner-border position-absolute top-50 start-50 translate-middle" role="status">
|
<div class="d-flex justify-content-center position-absolute top-50 start-50">
|
||||||
<span class="visually-hidden">Cargando</span>
|
<div class="spinner-border" role="status">
|
||||||
</div>
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
{#if $isAuthenticated}
|
||||||
|
{@render componente()}
|
||||||
{:else}
|
{:else}
|
||||||
{#if $isAuthenticated}
|
{window.location.replace('/')}
|
||||||
{@render componente()}
|
|
||||||
{:else}
|
|
||||||
{navigate('/')}
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|||||||
5
Front/src/Componentes/css/dotted-line.css
Normal file
5
Front/src/Componentes/css/dotted-line.css
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.dotted-line {
|
||||||
|
border: none;
|
||||||
|
border-top: 2px dashed #757575; /* Línea punteada de 2px de grosor y color negro */
|
||||||
|
margin: 20px 0; /* Márgenes opcionales */
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { urlG } from "../stores/urlStore";
|
import { urlG } from "../stores/urlStore";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
let { canthabitaciones, id, letra, piso, tipo, ubicacion, servicios } = $props();
|
let { canthabitaciones, id, letra, piso, tipo, ubicacion, servicios, monto } = $props();
|
||||||
let serviciosSeleccionados: string[] = $state([]);
|
let serviciosSeleccionados: string[] = $state([]);
|
||||||
const serviciosDisponibles = ["Gas", "Internet", "Telefono", "Luz"];
|
const serviciosDisponibles = ["Gas", "Internet", "Telefono", "Luz"];
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
ubicacion,
|
ubicacion,
|
||||||
email,
|
email,
|
||||||
servicios: serviciosSeleccionados,
|
servicios: serviciosSeleccionados,
|
||||||
|
monto
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@@ -116,6 +117,17 @@
|
|||||||
/>
|
/>
|
||||||
<label for="piso">Piso</label>
|
<label for="piso">Piso</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="monto"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={monto}
|
||||||
|
min="1"
|
||||||
|
placeholder={monto}
|
||||||
|
/>
|
||||||
|
<label for="monto">Monto</label>
|
||||||
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
106
Front/src/paginas/AdminPropiedades.svelte
Normal file
106
Front/src/paginas/AdminPropiedades.svelte
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import PanelBusqueda from "../Componentes/AdminPanelBusqueda.svelte";
|
||||||
|
import BotonVolverArriba from "../Componentes/BotonVolverArriba.svelte";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
import type { AdminParametrosBusqueda, PropiedadAdmin, PropiedadDto } from "../types";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import AdminPropiedad from "../Componentes/AdminPropiedad.svelte";
|
||||||
|
import PaginacionStepper from "../Componentes/PaginacionStepper.svelte";
|
||||||
|
|
||||||
|
|
||||||
|
const token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
let showButton: boolean = $state(false);
|
||||||
|
let modaldata: string = $state("");
|
||||||
|
let cantpag:number = $state(1);
|
||||||
|
let Propiedades:PropiedadAdmin[] = $state([]);
|
||||||
|
|
||||||
|
let p: AdminParametrosBusqueda = $state({
|
||||||
|
cantidadhabitaciones: 0,
|
||||||
|
pag: 1,
|
||||||
|
servicios: "",
|
||||||
|
tipopropiedad: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
cargaPropiedades();
|
||||||
|
window.addEventListener("scroll", handleScroll);
|
||||||
|
return () => window.removeEventListener("scroll", handleScroll);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleScroll = () => {
|
||||||
|
showButton = window.scrollY > 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function cargaPropiedades() {
|
||||||
|
try{
|
||||||
|
const [response, response2] = await Promise.all([
|
||||||
|
fetch($urlG+"/api/admin/busqueda/paginada?cantidadHabitaciones="+p.cantidadhabitaciones+"&tipoPropiedad="+p.tipopropiedad+"&servicios="+p.servicios+"&pag="+p.pag, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
fetch($urlG+"/api/admin/busqueda/cantPag?cantidadHabitaciones="+p.cantidadhabitaciones+"&tipoPropiedad="+p.tipopropiedad+"&servicios="+p.servicios, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (response.ok && response2.ok) {
|
||||||
|
const [data, data2] = await Promise.all([response.json(),response2.json()]);
|
||||||
|
Propiedades = data;
|
||||||
|
cantpag = data2.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modaldata = "Fallo la request";
|
||||||
|
}catch {
|
||||||
|
modaldata = "Fallo al intentar obtener la lista de propiedades";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryPag(a:number){
|
||||||
|
p.pag = a;
|
||||||
|
cargaPropiedades();
|
||||||
|
}
|
||||||
|
function querybusc(a:AdminParametrosBusqueda) {
|
||||||
|
p = a;
|
||||||
|
cargaPropiedades();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=> !!(modaldata = "")}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<BarraHorizontalConTexto text="Administracion Propiedades"/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col col-md-8 order-2">
|
||||||
|
{#each Propiedades as p }
|
||||||
|
<AdminPropiedad prop={p} modal={(a:string)=> modaldata = a} />
|
||||||
|
<br>
|
||||||
|
{/each}
|
||||||
|
<PaginacionStepper currentPag={p.pag} {queryPag} {cantpag}/>
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-4 order-1">
|
||||||
|
<PanelBusqueda Params={querybusc} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if showButton }
|
||||||
|
<div transition:fade={{duration:100}}>
|
||||||
|
<BotonVolverArriba/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
241
Front/src/paginas/AdminUsuarios.svelte
Normal file
241
Front/src/paginas/AdminUsuarios.svelte
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import type { Cliente, Grupo } from "../types";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import { fade, fly } from "svelte/transition";
|
||||||
|
|
||||||
|
let Clientes: Cliente[] = $state([]);
|
||||||
|
let Grupos:any[] = $state([]);
|
||||||
|
let modaldata = $state();
|
||||||
|
let token = sessionStorage.getItem("token");
|
||||||
|
let showAddmenu: boolean = $state(false);
|
||||||
|
|
||||||
|
let grupo:string = $state("");
|
||||||
|
let SelCliente: Cliente = $state(null);
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
try{
|
||||||
|
const response = await fetch($urlG+"/api/admin/clientes", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (response.ok) {
|
||||||
|
let data: Cliente[] = await response.json();
|
||||||
|
Clientes = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modaldata = "fallo al asignar la lista de clientes";
|
||||||
|
} catch {
|
||||||
|
modaldata = "fallo al intentar obtener la lista de clientes";
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
async function cargaGrupos(cli: Cliente){
|
||||||
|
try {
|
||||||
|
const response = await fetch($urlG+"/api/admin/clientes/grupo?Dni="+cli.dni, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (response.ok){
|
||||||
|
let data = await response.json();
|
||||||
|
Grupos = data;
|
||||||
|
showAddmenu = true;
|
||||||
|
SelCliente = cli;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modaldata = await response.json();
|
||||||
|
} catch {
|
||||||
|
modaldata = "no se pudo obtener la lista de grupos";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function bajaCliente(event:Event, cli:Cliente) {
|
||||||
|
//WIP añadir una flag para que muestre que no se pudo dar se alta/baja
|
||||||
|
event.stopPropagation();
|
||||||
|
try {
|
||||||
|
const response = await fetch($urlG+"/api/admin/cliente?Dni="+cli.dni, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(response.ok){
|
||||||
|
let data = await response.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
cli.habilitado = !cli.habilitado;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
modaldata = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
async function añadirGrupo(e:Event, cli: Cliente, grupo:string){
|
||||||
|
e.preventDefault();
|
||||||
|
if (cli.dni == 0 || cli.email == "" || grupo == ""){
|
||||||
|
modaldata = "No se selecciono un cliente o Grupo";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const email = cli.email;
|
||||||
|
try {
|
||||||
|
const response = await fetch($urlG+"/api/admin/cliente/addGrupo", {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
'Content-Type' : 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({email, grupo})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok){
|
||||||
|
let data = await response.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
cargaGrupos(cli);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = await response.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
} catch {
|
||||||
|
modaldata = "Falla la conexion al servidor";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function BajaGrupo(e:Event, cli: Cliente, grupo:string){
|
||||||
|
e.preventDefault();
|
||||||
|
if (cli.dni == 0 || cli.email == "" || grupo == ""){
|
||||||
|
modaldata = "No se selecciono un cliente o Grupo";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const email = cli.email;
|
||||||
|
if (grupo === "Propietario"){
|
||||||
|
if (confirm("Sos propietario si te desactivas de ese rol tus propiedades se van a dar de baja, Estas seguro?") == false) return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await fetch($urlG+"/api/admin/cliente/rmGrupo", {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
'Content-Type' : 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({email, grupo})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok){
|
||||||
|
let data = await response.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
cargaGrupos(cli);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = await response.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
} catch {
|
||||||
|
modaldata = "Falla la conexion al servidor";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=> !!(modaldata = "")}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="content-fluid align-items-start">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col" style="padding-right: 2px;">
|
||||||
|
<BarraHorizontalConTexto text="Clientes"/>
|
||||||
|
|
||||||
|
<div style="height:70vh; overflow-y: auto; max-width: 100%">
|
||||||
|
<table class="table table-responsive table-sm table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Dni</th>
|
||||||
|
<th>Nombre/Apellido</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each Clientes as cli}
|
||||||
|
<tr onclick={() => cargaGrupos(cli)} in:fade>
|
||||||
|
<td>{cli.dni}</td>
|
||||||
|
<td>{cli.nombre}</td>
|
||||||
|
<td>{cli.email}</td>
|
||||||
|
<td>
|
||||||
|
{#if cli.habilitado}
|
||||||
|
<button class="btn btn-outline-warning" onclick={(e) => bajaCliente(e, cli)}>
|
||||||
|
Baja
|
||||||
|
</button>
|
||||||
|
{:else}
|
||||||
|
<button class="btn btn-outline-success" onclick={(e) => bajaCliente(e, cli)}>
|
||||||
|
Alta
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col"style="padding-left: 2px;">
|
||||||
|
<BarraHorizontalConTexto text="Grupos del Cliente Seleccionado"/>
|
||||||
|
<table class="table table-striped table-responsive table-sm table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Descripcion</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#if Grupos.length>0}
|
||||||
|
|
||||||
|
{#each Grupos as g}
|
||||||
|
<tr in:fade>
|
||||||
|
<td>{g.id}</td>
|
||||||
|
<td>{g.descripcion}</td>
|
||||||
|
<td><button class="btn btn-outline-danger" onclick={(e)=>BajaGrupo(e, SelCliente, g.descripcion)}>Baja</button></td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
{:else if SelCliente != null}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">Este Cliente no tiene Grupos</td>
|
||||||
|
</tr>
|
||||||
|
{:else}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">Seleccione un cliente para ver sus grupos</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{#if showAddmenu}
|
||||||
|
<div in:fade>
|
||||||
|
<BarraHorizontalConTexto text="Añadir Grupos al Usuario"/>
|
||||||
|
<form class="card card-body" onsubmit={(e) => añadirGrupo(e,SelCliente, grupo)}>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="userRole" class="form-label">Seleccionar Grupo</label>
|
||||||
|
<select id="userRole" class="form-select" bind:value={grupo}>
|
||||||
|
<option value="Propietario">Propietario</option>
|
||||||
|
<option value="Inquilino">Inquilino</option>
|
||||||
|
<option value="Admin">Admin</option>
|
||||||
|
<option value="Informes">Informes</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary" type="submit">Añadir</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
92
Front/src/paginas/BusquedaPropiedades.svelte
Normal file
92
Front/src/paginas/BusquedaPropiedades.svelte
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import PublicacionPropiedad from "../Componentes/PublicacionPropiedad.svelte";
|
||||||
|
import PanelBusqueda from "../Componentes/PanelBusqueda.svelte";
|
||||||
|
import VolverArriba from "../Componentes/BotonVolverArriba.svelte";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
import {urlG} from "../stores/urlStore"
|
||||||
|
import type { PropiedadDto } from "../types";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import { text } from "@sveltejs/kit";
|
||||||
|
|
||||||
|
|
||||||
|
let showButton = $state(false);
|
||||||
|
let propiedades: PropiedadDto[] = $state([]);
|
||||||
|
|
||||||
|
let token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
const handleScroll = () => {
|
||||||
|
showButton = window.scrollY > 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
checkparametros()?
|
||||||
|
busqueda():
|
||||||
|
cargaPropiedades();
|
||||||
|
|
||||||
|
window.addEventListener("scroll", handleScroll);
|
||||||
|
return () => window.removeEventListener("scroll", handleScroll);
|
||||||
|
});
|
||||||
|
|
||||||
|
function checkparametros(){
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
|
if (params.has('cantidadHabitaciones') && params.has('tipoPropiedad')
|
||||||
|
&& params.has('servicios') ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
async function cargaPropiedades(){
|
||||||
|
const response = await fetch(String($urlG)+"/api/propiedades", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (response.ok){
|
||||||
|
propiedades = await response.json();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function busqueda(){
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
let hab = params.get('cantidadHabitaciones');
|
||||||
|
let tipo = params.get('tipoPropiedad');
|
||||||
|
let serv = params.get('servicios');
|
||||||
|
|
||||||
|
const response = await fetch(String($urlG)+"/api/busqueda"+"?cantidadHabitaciones="+hab+
|
||||||
|
"&tipoPropiedad="+tipo+"&servicios="+serv, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (response.ok){
|
||||||
|
propiedades = await response.json();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<BarraHorizontalConTexto text="Busqueda Propiedades"/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col col-md-8 order-2">
|
||||||
|
{#each propiedades as item}
|
||||||
|
<PublicacionPropiedad prop={item} />
|
||||||
|
<br>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 order-1">
|
||||||
|
<PanelBusqueda/>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{#if showButton }
|
||||||
|
<div transition:fade={{duration:100}}>
|
||||||
|
<VolverArriba/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||||
import type { PropiedadDto } from "../types";
|
import type { PropiedadDto } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
|
||||||
let propiedades = writable<PropiedadDto[]>([]);
|
let propiedades = writable<PropiedadDto[]>([]);
|
||||||
let email = localStorage.getItem("email");
|
let email = localStorage.getItem("email");
|
||||||
@@ -13,7 +15,7 @@
|
|||||||
|
|
||||||
onMount(async ()=> {
|
onMount(async ()=> {
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario", {
|
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
@@ -39,7 +41,8 @@
|
|||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
<div class="container table-responsive">
|
<div class="container table-responsive">
|
||||||
<table class="table-responsive table table-striped">
|
<BarraHorizontalConTexto text="Propiedades dadas de Alta"/>
|
||||||
|
<table class="container-fluid table-responsive table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
@@ -49,12 +52,13 @@
|
|||||||
<th>Piso</th>
|
<th>Piso</th>
|
||||||
<th>Tipo</th>
|
<th>Tipo</th>
|
||||||
<th>Servicios</th>
|
<th>Servicios</th>
|
||||||
|
<th>Monto</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $propiedades as propiedad}
|
{#each $propiedades as propiedad}
|
||||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} />
|
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} monto={propiedad.monto} />
|
||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||||
import type { PropiedadDto } from "../types";
|
import type { PropiedadDto } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
|
||||||
let propiedades = writable<PropiedadDto[]>([]);
|
let propiedades = writable<PropiedadDto[]>([]);
|
||||||
let email = localStorage.getItem("email");
|
let email = localStorage.getItem("email");
|
||||||
@@ -13,7 +15,7 @@
|
|||||||
|
|
||||||
onMount(async ()=> {
|
onMount(async ()=> {
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario/Bajas", {
|
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario/Bajas", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
@@ -38,8 +40,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
<div class="container table-responsive">
|
<div class="container table-responsive">
|
||||||
<table class="table-responsive table table-striped">
|
<BarraHorizontalConTexto text="Propiedades dadas de Baja"/>
|
||||||
|
<table class="table-responsive table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
@@ -49,12 +53,13 @@
|
|||||||
<th>Piso</th>
|
<th>Piso</th>
|
||||||
<th>Tipo</th>
|
<th>Tipo</th>
|
||||||
<th>Servicios</th>
|
<th>Servicios</th>
|
||||||
|
<th>Monto</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $propiedades as propiedad}
|
{#each $propiedades as propiedad}
|
||||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} btnbaja={"Alta"}/>
|
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} btnbaja={"Alta"} monto={propiedad.monto}/>
|
||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
500
Front/src/paginas/Notificaciones.svelte
Normal file
500
Front/src/paginas/Notificaciones.svelte
Normal file
@@ -0,0 +1,500 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import type { GaranteDto, MensajeDto } from "../types";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import ModalPrecontrato from "../Componentes/ModalPrecontrato.svelte";
|
||||||
|
import ModalAddGarantes from "../Componentes/ModalAddGarantes.svelte";
|
||||||
|
import ModalCheckYContrato from "../Componentes/ModalCheckYContrato.svelte";
|
||||||
|
import { self } from "svelte/legacy";
|
||||||
|
import ModalVeryAceptarContrato from "../Componentes/ModalVeryAceptarContrato.svelte";
|
||||||
|
import { getRequest } from "@sveltejs/kit/node";
|
||||||
|
import { json } from "@sveltejs/kit";
|
||||||
|
|
||||||
|
const token = sessionStorage.getItem("token");
|
||||||
|
let mensajes: MensajeDto[] = $state([]);
|
||||||
|
let showspinner:boolean =$state(false);
|
||||||
|
let mostrarleidos: boolean = $state(false);
|
||||||
|
let modaldata:string =$state("");
|
||||||
|
let Selmens: MensajeDto = $state({accion:""});
|
||||||
|
|
||||||
|
let show:boolean = $state(false);
|
||||||
|
let setCantGarantes = $state(0);
|
||||||
|
|
||||||
|
let garantes:GaranteDto[] = $state([]);
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
SinLeer();
|
||||||
|
})
|
||||||
|
|
||||||
|
async function SinLeer() {
|
||||||
|
mostrarleidos = false;
|
||||||
|
showspinner = true;
|
||||||
|
try{
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones?leido="+mostrarleidos, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
mensajes = data;
|
||||||
|
showspinner = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let errordata = await responce.json();
|
||||||
|
modaldata = errordata.message;
|
||||||
|
} catch{
|
||||||
|
modaldata = "no se pudo obtener notificaciones";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function Leidos() {
|
||||||
|
mostrarleidos = true;
|
||||||
|
showspinner = true;
|
||||||
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones?leido="+true, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
mensajes = data;
|
||||||
|
showspinner = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let errordata = await responce.json();
|
||||||
|
modaldata = errordata.message;
|
||||||
|
} catch {
|
||||||
|
modaldata = "no se pudo obtener notificaciones";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function marcarleido( fecha: Date, email: string, men:MensajeDto ) {
|
||||||
|
show = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones", {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({fecha, email}),
|
||||||
|
});
|
||||||
|
if (responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dataerror = await responce.json();
|
||||||
|
modaldata = dataerror.message;
|
||||||
|
} catch {
|
||||||
|
modaldata = "no se pudo marcar como leido";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function abrirModal(mensaje: MensajeDto) {
|
||||||
|
if (mensaje.accion === "Nuevo Alquiler") {
|
||||||
|
Selmens = { ...mensaje };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mensaje.accion === "Carge Garantes") {
|
||||||
|
Selmens = { ...mensaje };
|
||||||
|
setCantGarantes = Number(Selmens.mensaje.split(" ").reverse()[1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mensaje.accion === "Check y Contrato"){
|
||||||
|
Selmens = {...mensaje};
|
||||||
|
let idcontrato = Number(Selmens.mensaje.split(" ").reverse()[0]);
|
||||||
|
obtenerListaGarantes(idcontrato);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mensaje.accion === "Aceptar Contrato") {
|
||||||
|
Selmens = {...mensaje};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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="+localStorage.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";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let fecha = Selmens.fecha.toString();
|
||||||
|
const datata = {
|
||||||
|
tieneopcionventa: data.opcionVenta,
|
||||||
|
mesesHastaAumento: data.mesesHastaAumento,
|
||||||
|
cantidadGarantes: data.cantGarantes,
|
||||||
|
idPropiedad: Selmens.propiedad,
|
||||||
|
fechaprimernotificacion: fecha,
|
||||||
|
emailInquilino: localStorage.getItem("email"),
|
||||||
|
emailPropietario: Selmens.receptor,
|
||||||
|
};
|
||||||
|
|
||||||
|
let responce = await fetch($urlG+"/api/contratos/precontrato", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(datata),
|
||||||
|
});
|
||||||
|
if(responce.ok) {
|
||||||
|
let dataaa = await responce.json();
|
||||||
|
modaldata = dataaa.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dataaa = await responce.json();
|
||||||
|
modaldata = dataaa.message;
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
modaldata = "fallo al intentar conectar con el servidor: "+e
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEnviarmensaje3(garantes: GaranteDto[]) {
|
||||||
|
try {
|
||||||
|
let dat = {
|
||||||
|
emailInquilino: localStorage.getItem("email") || "",
|
||||||
|
idpropiedad: Selmens.propiedad,
|
||||||
|
fecha: Selmens.fecha,
|
||||||
|
garantes: garantes
|
||||||
|
}
|
||||||
|
|
||||||
|
let responce = await fetch($urlG+"/api/contratos/addGarantes", {
|
||||||
|
method : "PUT",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(dat),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dataaa = await responce.json();
|
||||||
|
modaldata = dataaa.message;
|
||||||
|
} catch {
|
||||||
|
modaldata = "no se pudo comunicar con el Servidor";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
Selmens.accion = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dataa = await responce.json();
|
||||||
|
modaldata = dataa.message;
|
||||||
|
return
|
||||||
|
}catch {
|
||||||
|
modaldata = "fallo al intentar conectar con el servidor";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEnviarmensaje4(file:File, idcontrato:string) {
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("idcontrato", idcontrato);
|
||||||
|
formdata.append("contrato", file);
|
||||||
|
formdata.append("ubicarnotificacion", Selmens.fecha);
|
||||||
|
try{
|
||||||
|
const responce = await fetch($urlG+"/api/contratos/subirContrato", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
},
|
||||||
|
body: formdata,
|
||||||
|
});
|
||||||
|
if (responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
return;
|
||||||
|
}catch{
|
||||||
|
modaldata="Fallo al intentar hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ObtenerContrato(idcontrato: number) {
|
||||||
|
if (Selmens.accion != "Aceptar Contrato") {
|
||||||
|
modaldata = "Hay algo mal comunicate con el administrador";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/contrato/getdocumento?idcontrato="+idcontrato, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!responce.ok) {
|
||||||
|
modaldata="Error al obtener el archivo";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let blob = await responce.blob();
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
window.open(blobUrl, '_blank');
|
||||||
|
setTimeout(() => URL.revokeObjectURL(blobUrl), 100000);
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo al intentar conectarse al servidor";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleAceptarContrato(idcontrato:number) {
|
||||||
|
if (idcontrato<=0){
|
||||||
|
modaldata="La idcontrato da 0 o menos comunicate con el administrador";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
let rq = {
|
||||||
|
idcontrato:idcontrato,
|
||||||
|
fecha:Selmens.fecha,
|
||||||
|
}
|
||||||
|
const responce = await fetch($urlG+"/api/contratos/aceptarContrato", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(rq),
|
||||||
|
});
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo la request";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handlerechazarcontrato(idcontrato:number) {
|
||||||
|
if (idcontrato<=0){
|
||||||
|
modaldata="La idcontrato da 0 o menos comunicate con el administrador";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
let rq = {
|
||||||
|
idcontrato:idcontrato,
|
||||||
|
fecha:Selmens.fecha
|
||||||
|
}
|
||||||
|
const responce = await fetch($urlG+"/api/contratos/rechazarPreContrato?idcontrato="+idcontrato, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(rq),
|
||||||
|
});
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo la request";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if Selmens.accion == "Nuevo Alquiler" }
|
||||||
|
<ModalPrecontrato onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje2} />
|
||||||
|
{:else if Selmens.accion == "Carge Garantes"}
|
||||||
|
<ModalAddGarantes maxGarantes={setCantGarantes} onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje3}/>
|
||||||
|
{:else if Selmens.accion == "Check y Contrato"}
|
||||||
|
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
||||||
|
{:else if Selmens.accion == "Aceptar Contrato"}
|
||||||
|
<ModalVeryAceptarContrato onClose={() => (Selmens.accion = "")} onConfirm={handleAceptarContrato} onCancel={handlerechazarcontrato} getContrato={ObtenerContrato} men={Selmens}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<br>
|
||||||
|
<BarraHorizontalConTexto text="Notificaciones"/>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div class="btn-group">
|
||||||
|
<button class="btn btn-primary" class:active={mostrarleidos==false} onclick={SinLeer} >Sin Leer</button>
|
||||||
|
<button class="btn btn-primary" class:active={mostrarleidos==true} onclick={Leidos} >Leidos</button>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="container-fluid" style="margin-top: 1cm;">
|
||||||
|
{#if showspinner}
|
||||||
|
<div class=" justify-content-center position-absolute top-50 start-50">
|
||||||
|
<div class="spinner-border" role="status"></div>
|
||||||
|
Cargando...
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<table class="table container-fluid table-responsive table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Remitente</th>
|
||||||
|
<th>Accion</th>
|
||||||
|
<th>Receptor</th>
|
||||||
|
<th>Mensaje</th>
|
||||||
|
<th>Fecha</th>
|
||||||
|
<th>Propiedad</th>
|
||||||
|
{#if mostrarleidos == false}
|
||||||
|
<th></th>
|
||||||
|
{/if}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{#if mensajes.length <= 0}
|
||||||
|
<tr>
|
||||||
|
<td colspan={mostrarleidos == false ? 6 : 5}>
|
||||||
|
<p>No hay Mensajes para leer</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{:else}
|
||||||
|
{#each mensajes as men}
|
||||||
|
<tr>
|
||||||
|
<td>{men.remitente}</td>
|
||||||
|
<td>{men.accion}</td>
|
||||||
|
<td>{men.receptor}</td>
|
||||||
|
<td>{men.mensaje}</td>
|
||||||
|
<td>{men.fecha}</td>
|
||||||
|
<td>{men.propiedad}</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{#if mostrarleidos == false && men.accion != "Rechazo Contrato" && men.accion != "Aceptado Contrato"}
|
||||||
|
<button
|
||||||
|
class="btn btn-outline-primary"
|
||||||
|
onclick={() => abrirModal(men)}>
|
||||||
|
Expandir
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{#if men.accion === "ContratoCancelado" || men.accion === "Rechazo Contrato" ||
|
||||||
|
men.accion === "Aceptado Contrato"}
|
||||||
|
<button
|
||||||
|
class="btn btn-outline-danger"
|
||||||
|
onclick={() => marcarleido(men.fecha, localStorage.getItem("email")|| "", men)}>
|
||||||
|
Marcar Leido
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { writable } from "svelte/store"; // Importar writable para los estados
|
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
import type { Propiedad } from "../types";
|
import type { Propiedad } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let propiedad: Propiedad = {
|
let propiedad: Propiedad = {
|
||||||
ubicacion: "",
|
ubicacion: "",
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
letra: "",
|
letra: "",
|
||||||
email: localStorage.getItem("email") || "",
|
email: localStorage.getItem("email") || "",
|
||||||
idtipropiedad: 1,
|
idtipropiedad: 1,
|
||||||
|
monto: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
let token = sessionStorage.getItem("token");
|
let token = sessionStorage.getItem("token");
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
mostrarModal = false;
|
mostrarModal = false;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
const response = await fetch(String($urlG)+"/api/propiedad", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
@@ -93,6 +94,17 @@
|
|||||||
/>
|
/>
|
||||||
<label for="piso">Piso</label>
|
<label for="piso">Piso</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="monto"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={propiedad.monto}
|
||||||
|
min="1"
|
||||||
|
placeholder="1"
|
||||||
|
/>
|
||||||
|
<label for="monto">Monto</label>
|
||||||
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<br>
|
<br>
|
||||||
<FormPostInq url="http://127.0.0.1:5007/api/inquilino"/>
|
<FormPostInq url={String($urlG)+"/api/inquilino"}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Login from "../Componentes/login.svelte"
|
import Login from "../Componentes/LoginPanel.svelte"
|
||||||
import Navbar from "../Componentes/NavBarLogin.svelte";
|
import Navbar from "../Componentes/NavBarLogin.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<br>
|
<br>
|
||||||
<FormPostInq url="http://127.0.0.1:5007/api/propietario"/>
|
<FormPostInq url={String($urlG)+'/api/propietario'}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { readable } from 'svelte/store';
|
|
||||||
|
|
||||||
export const urlG = readable('http://localhost:5007');
|
|
||||||
3
Front/src/stores/urlStore.ts
Normal file
3
Front/src/stores/urlStore.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { readable, type Readable } from 'svelte/store';
|
||||||
|
|
||||||
|
export const urlG: Readable<string> = readable('http://localhost:5007');
|
||||||
49
Front/src/types.d.ts
vendored
49
Front/src/types.d.ts
vendored
@@ -5,13 +5,40 @@ export type PropiedadDto = {
|
|||||||
piso: string | null,
|
piso: string | null,
|
||||||
letra: string | null,
|
letra: string | null,
|
||||||
canthabitaciones: number,
|
canthabitaciones: number,
|
||||||
servicios: string
|
servicios: string,
|
||||||
|
monto: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AdminParametrosBusqueda = {
|
||||||
|
cantidadhabitaciones: number=0,
|
||||||
|
tipopropiedad: number=0,
|
||||||
|
servicios: string="",
|
||||||
|
pag: number=1
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PropiedadAdmin = {
|
||||||
|
id: number,
|
||||||
|
ubicacion: string,
|
||||||
|
tipo: string,
|
||||||
|
piso: string | null,
|
||||||
|
letra: string | null,
|
||||||
|
canthabitaciones: number,
|
||||||
|
servicios: string,
|
||||||
|
monto: number,
|
||||||
|
estado: string
|
||||||
}
|
}
|
||||||
export type Permiso = {
|
export type Permiso = {
|
||||||
id: number;
|
id: number;
|
||||||
descripcion: string;
|
descripcion: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Cliente = {
|
||||||
|
dni: number,
|
||||||
|
nombre: string,
|
||||||
|
email: string,
|
||||||
|
habilitado: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type Grupo = {
|
export type Grupo = {
|
||||||
id: number;
|
id: number;
|
||||||
nombre: string;
|
nombre: string;
|
||||||
@@ -25,4 +52,24 @@ export type Propiedad = {
|
|||||||
letra: string,
|
letra: string,
|
||||||
email: string,
|
email: string,
|
||||||
idtipropiedad: number,
|
idtipropiedad: number,
|
||||||
|
monto: number
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MensajeDto = {
|
||||||
|
remitente: string,
|
||||||
|
accion: string,
|
||||||
|
receptor: string,
|
||||||
|
mensaje: string,
|
||||||
|
fecha: Date,
|
||||||
|
propiedad: string,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GaranteDto = {
|
||||||
|
Dni: number;
|
||||||
|
Nombre: string;
|
||||||
|
Apellido: string;
|
||||||
|
Domicilio: string;
|
||||||
|
Celular: string;
|
||||||
|
Domiciliolaboral: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,5 +17,4 @@
|
|||||||
"moduleDetection": "force"
|
"moduleDetection": "force"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
|
||||||
}
|
}
|
||||||
|
|||||||
147
Modelo/RepositorioContratos.cs
Normal file
147
Modelo/RepositorioContratos.cs
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
using Entidades;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Modelo;
|
||||||
|
public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||||
|
public IQueryable<Contrato>? ObtenerContratosPorEmailInquilino(string email) {
|
||||||
|
var con = Context;
|
||||||
|
try{
|
||||||
|
var listcont = con.Contratos.Where(x=>x.DniinquilinoNavigation.Email == email);
|
||||||
|
return listcont;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CargaPrecontrato(Contrato? c = null, Notificacione? n = null) {
|
||||||
|
if (c == null || c.Habilitado == 1) return false;
|
||||||
|
if (n == null) return false;
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
var prop = con.Propiedades.FirstOrDefault(x=>x.Id==c.Idpropiedad);
|
||||||
|
if (prop == null) return false;
|
||||||
|
prop.Idestado = 2;
|
||||||
|
|
||||||
|
c.Id = (con.Contratos.Any() ? con.Contratos.Max(x => x.Id) : 0) + 1;
|
||||||
|
c.Monto = prop.Monto;
|
||||||
|
|
||||||
|
con.Contratos.Add(c);
|
||||||
|
con.Notificaciones.Add(n);
|
||||||
|
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
public bool CargaGarantes(List<Garante> gar, string emailInquilino, int idpropiedad) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation).Include(x=>x.Idgarantes)
|
||||||
|
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||||
|
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||||
|
x.Habilitado == 0 &&
|
||||||
|
x.Cancelado == 0);
|
||||||
|
|
||||||
|
if (contr == null) return false;
|
||||||
|
int inicial = (con.Garantes.Any()? con.Garantes.Max(x=>x.Id): 0) + 1;
|
||||||
|
foreach (var i in gar) {
|
||||||
|
i.Id = inicial;
|
||||||
|
inicial++;
|
||||||
|
con.Garantes.Add(i);
|
||||||
|
contr.Idgarantes.Add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CantidadGarantesEncontrato(string emailInquilino, int idpropiedad) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
||||||
|
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||||
|
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||||
|
x.Habilitado == 0 &&
|
||||||
|
x.Cancelado == 0);
|
||||||
|
if (contr == null) return 0;
|
||||||
|
return contr.Cantgarantemin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contrato? ObtenerContrato(string emailInquilino, int idpropiedad) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
||||||
|
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||||
|
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||||
|
x.Habilitado == 0 &&
|
||||||
|
x.Cancelado == 0);
|
||||||
|
if (contr == null) return null;
|
||||||
|
return contr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CancelarPrecontrato(string emailInquilino, int idpropiedad) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
||||||
|
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||||
|
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||||
|
x.Habilitado == 0 &&
|
||||||
|
x.Cancelado == 0);
|
||||||
|
|
||||||
|
if (contr == null || contr.IdpropiedadNavigation == null) return false;
|
||||||
|
contr.Cancelado = 1;
|
||||||
|
contr.IdpropiedadNavigation.Idestado = 1;
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contrato? ObtenerPreContratoPorId(long idcontrato) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contr = con.Contratos
|
||||||
|
.Include(x=>x.DnipropietarioNavigation)
|
||||||
|
.Include(x=>x.Idgarantes)
|
||||||
|
.Where(x=>x.Cancelado == 0 && x.Habilitado == 0)
|
||||||
|
.FirstOrDefault(x=>x.Id == idcontrato);
|
||||||
|
if (contr == null) return null;
|
||||||
|
return contr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddUrl(long id, string nuevoNombreArchivo) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? contrato = con.Contratos
|
||||||
|
.FirstOrDefault(x=>x.Id == id);
|
||||||
|
if (contrato == null) return false;
|
||||||
|
contrato.UrlContrato = nuevoNombreArchivo;
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AceptarContrato(long idcontrato) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? cont = con.Contratos
|
||||||
|
.Include(x=>x.Idcanons)
|
||||||
|
.Include(x=>x.IdpropiedadNavigation)
|
||||||
|
.FirstOrDefault(x=>x.Id ==idcontrato &&
|
||||||
|
x.Habilitado ==0 &&
|
||||||
|
x.Cancelado == 0);
|
||||||
|
|
||||||
|
if (cont == null || cont.IdpropiedadNavigation==null) return false;
|
||||||
|
|
||||||
|
cont.Habilitado = 1;
|
||||||
|
var fecha = cont.Fechainicio;
|
||||||
|
|
||||||
|
for (int i = 0; i < cont.MesesHastaAumento; i++) {
|
||||||
|
Canon can = new Canon{
|
||||||
|
Fecha = fecha.AddMonths(i),
|
||||||
|
Monto = cont.IdpropiedadNavigation.Monto,
|
||||||
|
Pagado = 0,
|
||||||
|
};
|
||||||
|
can.Id = (con.Canons.Any()? con.Canons.Count() :0)+1+i;
|
||||||
|
|
||||||
|
|
||||||
|
con.Canons.Add(can);
|
||||||
|
cont.Idcanons.Add(can);
|
||||||
|
}
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CancelarPrecontrato(long idcontrato) {
|
||||||
|
var con = Context;
|
||||||
|
Contrato? cont = con.Contratos.Include(x=>x.IdpropiedadNavigation).FirstOrDefault(x=>x.Id ==idcontrato && x.Habilitado ==0);
|
||||||
|
if (cont == null|| cont.IdpropiedadNavigation==null) return false;
|
||||||
|
cont.Cancelado = 1;
|
||||||
|
cont.IdpropiedadNavigation.Idestado = 1;
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#if DEBUG
|
|
||||||
|
|
||||||
using Entidades;
|
using Entidades;
|
||||||
|
using Entidades.Admin;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Modelo;
|
namespace Modelo;
|
||||||
@@ -23,6 +22,28 @@ public class RepositorioGrupos: RepositorioBase<RepositorioGrupos> {
|
|||||||
var con = Context;
|
var con = Context;
|
||||||
return con.Grupos.Where(x=>x.Nombre == grupo).SelectMany(x => x.Idpermisos);
|
return con.Grupos.Where(x=>x.Nombre == grupo).SelectMany(x => x.Idpermisos);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
public IQueryable<GrupoAdmin> ObtenerGruposPorDni(long Dni) {
|
||||||
|
var con = Context;
|
||||||
|
var grupos = con.Clientes.Where(x=>x.Dni == Dni).SelectMany(x=>x.Idgrupos)
|
||||||
|
.Select(x=> new GrupoAdmin{
|
||||||
|
Id = x.Id,
|
||||||
|
Descripcion = x.Nombre,
|
||||||
|
});
|
||||||
|
return grupos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckGrupos(string token, string grupo){
|
||||||
|
var con = Context;
|
||||||
|
Cliente? cli = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Token == token);
|
||||||
|
if (cli == null) return false;
|
||||||
|
|
||||||
|
Grupo? gru = con.Grupos.FirstOrDefault(x=>x.Nombre == grupo);
|
||||||
|
if (gru == null) return false;
|
||||||
|
|
||||||
|
if (cli.Idgrupos.Contains(gru)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Entidades;
|
||||||
using Entidades.Dto;
|
using Entidades.Dto;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@@ -15,5 +16,15 @@ public class RepositorioInquilinos: RepositorioBase<RepositorioInquilinos> {
|
|||||||
return Context.Database.SqlQuery<InquilinoDto>(sqlq);
|
return Context.Database.SqlQuery<InquilinoDto>(sqlq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cliente? ObtenerInquilinoPorEmail(string Email){
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
Cliente? cli = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Email == Email);
|
||||||
|
if (cli == null || cli.Dni == 0) return null;
|
||||||
|
|
||||||
|
Grupo? gru = cli.Idgrupos.FirstOrDefault(x=>x.Id == 2);
|
||||||
|
if (gru == null) return null;
|
||||||
|
|
||||||
|
return cli;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
45
Modelo/RepositorioNotificaciones.cs
Normal file
45
Modelo/RepositorioNotificaciones.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using Entidades.Dto;
|
||||||
|
using Entidades;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using Org.BouncyCastle.Math.EC.Rfc7748;
|
||||||
|
|
||||||
|
namespace Modelo;
|
||||||
|
|
||||||
|
public class RepositorioNotificaciones : RepositorioBase<RepositorioNotificaciones> {
|
||||||
|
public bool MarcarComoLeido(long dni, DateTime? fecha) {
|
||||||
|
if (fecha == null) return false;
|
||||||
|
|
||||||
|
var con = Context;
|
||||||
|
Notificacione? noti = con.Notificaciones.FirstOrDefault(x=> x.Dnicliente == dni && x.Fecha == fecha);
|
||||||
|
if (noti == null) return false;
|
||||||
|
|
||||||
|
noti.Leido = true;
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AltaNotificacion(Notificacione n) {
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
con.Notificaciones.Add(n);
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<Notificacione> ObtenerNotificacionesDeUsuario(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
var notis = con.Notificaciones
|
||||||
|
.Include(x=>x.IdpropiedadNavigation)
|
||||||
|
.Include(x=>x.DniremitenteNavigation)
|
||||||
|
.Where(x => x.Dnicliente == dni);
|
||||||
|
return notis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HayNotis(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
bool hay = con.Notificaciones.Where(x=>x.Leido == false).Any();
|
||||||
|
return hay;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ public class RepositorioPermisos: RepositorioBase<RepositorioPermisos> {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
//Esto esta comentado porque antes pasaba el string del path de la url, es una mala idea a muchos niveles
|
//Esto esta comentado porque antes pasaba el string del path de la url, es una mala idea a muchos niveles
|
||||||
|
// abajo un comentario viejo mio
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
//me inspiré y hice un regex pero si eliminaba los primeros 8(?) caracteres del string era lo mismo
|
//me inspiré y hice un regex pero si eliminaba los primeros 8(?) caracteres del string era lo mismo
|
||||||
//Match match = Regex.Match(path, @"^/accion/(\d+)$");
|
//Match match = Regex.Match(path, @"^/accion/(\d+)$");
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Entidades;
|
using Entidades;
|
||||||
|
using Entidades.Admin;
|
||||||
using Entidades.Dto;
|
using Entidades.Dto;
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Identity.Client;
|
||||||
using Modelo;
|
using Modelo;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
@@ -11,9 +12,14 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
|||||||
|
|
||||||
public IQueryable<PropiedadesDto> ListarPropiedades(){
|
public IQueryable<PropiedadesDto> ListarPropiedades(){
|
||||||
FormattableString sqlq = $"""
|
FormattableString sqlq = $"""
|
||||||
SELECT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS TipoPropiedad FROM Propiedades p
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
JOIN EstadoPropiedad ep ON p.idestado = 1
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
GROUP BY p.id
|
||||||
""";
|
""";
|
||||||
|
|
||||||
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
@@ -21,14 +27,9 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Propiedade? ObtenerPropiedadPorId(int Id) {
|
public Propiedade? ObtenerPropiedadPorId(int Id) {
|
||||||
|
var con = Context;
|
||||||
|
Propiedade? prop = con.Propiedades.Include(x=>x.DnipropietarioNavigation).FirstOrDefault(x=>x.Id == Id);
|
||||||
|
|
||||||
FormattableString sqlq = $"""
|
|
||||||
SELECT * FROM Propiedades p
|
|
||||||
WHERE p.id = {Id}
|
|
||||||
LIMIT 1
|
|
||||||
""";
|
|
||||||
|
|
||||||
Propiedade? prop = Context.Database.SqlQuery<Propiedade>(sqlq).First();
|
|
||||||
if (prop == null || prop.Id == 0) {
|
if (prop == null || prop.Id == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -36,35 +37,36 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
|||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AñadirPropiedad(Propiedade? prop) {
|
public bool AñadirPropiedad(Propiedade? prop) {
|
||||||
if (prop == null) return false;
|
if (prop == null) return false;
|
||||||
|
|
||||||
var con = Context;
|
var con = Context;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(prop.Letra)) prop.Letra = "_";
|
if (string.IsNullOrEmpty(prop.Letra)) prop.Letra = "_";
|
||||||
|
|
||||||
var filasInsertadasParam = new MySqlParameter("@p_filas_insertadas", SqlDbType.Int)
|
var filasInsertadasParam = new MySqlParameter("@p_filas_insertadas", SqlDbType.Int)
|
||||||
{
|
{
|
||||||
Direction = ParameterDirection.Output
|
Direction = ParameterDirection.Output
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ejecutar el procedimiento almacenado
|
// Ejecutar el procedimiento almacenado
|
||||||
var row = con.Database.ExecuteSqlRaw(
|
var row = con.Database.ExecuteSqlRaw(
|
||||||
$"""
|
$"""
|
||||||
CALL InsertarPropiedad(@p_ubicacion, @p_cant_habitaciones, @p_piso, @p_letra,
|
CALL InsertarPropiedad(@p_ubicacion, @p_cant_habitaciones, @p_piso, @p_letra,
|
||||||
@p_dni_propietario, @p_id_tipo_propiedad, @p_filas_insertadas)
|
@p_dni_propietario, @p_id_tipo_propiedad, @p_monto, @p_filas_insertadas)
|
||||||
""",
|
""",
|
||||||
new MySqlParameter("@p_ubicacion", prop.Ubicacion),
|
new MySqlParameter("@p_ubicacion", prop.Ubicacion),
|
||||||
new MySqlParameter("@p_cant_habitaciones", prop.Canthabitaciones),
|
new MySqlParameter("@p_cant_habitaciones", prop.Canthabitaciones),
|
||||||
new MySqlParameter("@p_piso", prop.Piso),
|
new MySqlParameter("@p_piso", prop.Piso),
|
||||||
new MySqlParameter("@p_letra", prop.Letra),
|
new MySqlParameter("@p_letra", prop.Letra),
|
||||||
new MySqlParameter("@p_dni_propietario", prop.Dnipropietario),
|
new MySqlParameter("@p_dni_propietario", prop.Dnipropietario),
|
||||||
new MySqlParameter("@p_id_tipo_propiedad", prop.Idtipropiedad),
|
new MySqlParameter("@p_id_tipo_propiedad", prop.Idtipropiedad),
|
||||||
filasInsertadasParam
|
new MySqlParameter("@p_monto",prop.Monto),
|
||||||
);
|
filasInsertadasParam
|
||||||
|
);
|
||||||
|
|
||||||
return (int)filasInsertadasParam.Value == 1? true: false;
|
return (int)filasInsertadasParam.Value == 1? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PatchPropiedad(Propiedade prop) {
|
public bool PatchPropiedad(Propiedade prop) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
@@ -77,6 +79,7 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
propi.Ubicacion = prop.Ubicacion;
|
propi.Ubicacion = prop.Ubicacion;
|
||||||
propi.Piso = prop.Piso;
|
propi.Piso = prop.Piso;
|
||||||
propi.Letra = prop.Letra;
|
propi.Letra = prop.Letra;
|
||||||
|
propi.Monto = prop.Monto;
|
||||||
|
|
||||||
propi.IdServicios.Clear();
|
propi.IdServicios.Clear();
|
||||||
foreach(Servicio ser in prop.IdServicios) {
|
foreach(Servicio ser in prop.IdServicios) {
|
||||||
@@ -90,7 +93,7 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
|
|
||||||
public IQueryable<PropiedadesDto> ObtenerPropiedadesPorEmail(string email) {
|
public IQueryable<PropiedadesDto> ObtenerPropiedadesPorEmail(string email) {
|
||||||
FormattableString sqlq = $"""
|
FormattableString sqlq = $"""
|
||||||
SELECT p.id, p.ubicacion as Ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as Tipo, GROUP_CONCAT(IFNULL(s.descripcion, '') SEPARATOR ', ') AS Servicios
|
SELECT p.id, p.ubicacion as Ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as Tipo, GROUP_CONCAT(IFNULL(s.descripcion, '') SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
FROM Propiedades p
|
FROM Propiedades p
|
||||||
JOIN Clientes c ON c.dni = p.dnipropietario
|
JOIN Clientes c ON c.dni = p.dnipropietario
|
||||||
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
||||||
@@ -106,7 +109,7 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
|
|
||||||
public IQueryable<PropiedadesDto> ObtenerPropiedadesDeBajaPorEmail(string email) {
|
public IQueryable<PropiedadesDto> ObtenerPropiedadesDeBajaPorEmail(string email) {
|
||||||
FormattableString sqlq = $"""
|
FormattableString sqlq = $"""
|
||||||
SELECT p.id, p.ubicacion as Ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as Tipo, GROUP_CONCAT(IFNULL(s.descripcion, '') SEPARATOR ', ') AS Servicios
|
SELECT p.id, p.ubicacion as Ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as Tipo, GROUP_CONCAT(IFNULL(s.descripcion, '') SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
FROM Propiedades p
|
FROM Propiedades p
|
||||||
JOIN Clientes c ON c.dni = p.dnipropietario
|
JOIN Clientes c ON c.dni = p.dnipropietario
|
||||||
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
||||||
@@ -153,8 +156,18 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool BajaServiciosAPropiedad(int idprop, List<int> idserv)
|
public bool BajaPropiedad(int id) {
|
||||||
{
|
var con = Context;
|
||||||
|
Propiedade? prop = con.Propiedades.FirstOrDefault(x=>x.Id == id);
|
||||||
|
|
||||||
|
if (prop == null||prop.Dnipropietario == 0) return false;
|
||||||
|
|
||||||
|
prop.Idestado = prop.Idestado == 3 ? 1 : 3;
|
||||||
|
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BajaServiciosAPropiedad(int idprop, List<int> idserv) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
Propiedade? prop = con.Propiedades.Include(x=>x.IdServicios).FirstOrDefault(x => x.Id == idprop);
|
Propiedade? prop = con.Propiedades.Include(x=>x.IdServicios).FirstOrDefault(x => x.Id == idprop);
|
||||||
if (prop == null) return false;
|
if (prop == null) return false;
|
||||||
@@ -170,5 +183,411 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorHabitaciones_Tipo_Servicios(int habitaciones, int tipo, string servicios) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {habitaciones} AND p.idtipropiedad = {tipo}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorHabitaciones_Tipo(int cantidadHabitaciones, int tipoPropiedad) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones} AND p.idtipropiedad = {tipoPropiedad}
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorServicios(string servicios) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorHabitaciones(int cantidadHabitaciones) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones}
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorTipo(int tipoPropiedad) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.idtipropiedad = {tipoPropiedad}
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorHabitaciones_Servicios(int cantidadHabitaciones, string servicios) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ObtenerPropiedesPorTipo_Servicios(int tipoPropiedad, string servicios) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.idtipropiedad = {tipoPropiedad}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BajaPropiedades(string email) {
|
||||||
|
var con = Context;
|
||||||
|
try {
|
||||||
|
IQueryable<Propiedade> listprop = con.Propiedades.Where(x=>x.DnipropietarioNavigation.Email == email);
|
||||||
|
foreach (var item in listprop) {
|
||||||
|
item.Idestado = 3;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesDto> ListarPropiedadesPorPagina(int pag) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = 1
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
///////////////ADMIN
|
||||||
|
public IQueryable<PropiedadesAdmin> ListarPropiedadesPorPaginaAdmin(int pag) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorHabitacionesPaginado(int cantidadHabitaciones, int pag) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones}
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorTipoPaginado(int tipoPropiedad, int pag) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.idtipropiedad = {tipoPropiedad}
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorHabitaciones_TipoPaginado(int cantidadHabitaciones, int tipoPropiedad, int pag) {
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones} AND p.idtipropiedad = {tipoPropiedad}
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorServiciosPaginado(string servicios, int pag) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorHabitaciones_Servicios_Paginado(int cantidadHabitaciones, string servicios, int pag) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {cantidadHabitaciones}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorTipo_Servicios_Paginado(int tipoPropiedad, string servicios, int pag) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.idtipropiedad = {tipoPropiedad}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<PropiedadesAdmin> ObtenerPropiedesPorHabitaciones_Tipo_Servicios_Paginado(int habitaciones, int tipo, string servicios, int pag) {
|
||||||
|
string serviciosEscapados = string.Join(",", servicios.Split(',').Select(s => s.Trim()));
|
||||||
|
FormattableString sqlq = $"""
|
||||||
|
SELECT DISTINCT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion AS Tipo,
|
||||||
|
GROUP_CONCAT(DISTINCT s.descripcion SEPARATOR ', ') AS Servicios, p.monto as Monto, ep.descripcion AS Estado
|
||||||
|
FROM Propiedades p
|
||||||
|
JOIN EstadoPropiedad ep ON p.idestado = ep.id
|
||||||
|
JOIN TipoPropiedad tp ON p.idtipropiedad = tp.id
|
||||||
|
JOIN Servicio_Propiedad sp on p.id =sp.idPropiedad
|
||||||
|
JOIN Servicios s on sp.idServicio =s.id
|
||||||
|
WHERE p.canthabitaciones = {habitaciones} AND p.idtipropiedad = {tipo}
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM Servicio_Propiedad sp2
|
||||||
|
JOIN Servicios s2 ON sp2.idServicio = s2.id
|
||||||
|
WHERE sp2.idPropiedad = p.id
|
||||||
|
AND FIND_IN_SET(s2.descripcion, {serviciosEscapados})
|
||||||
|
)
|
||||||
|
GROUP BY p.id
|
||||||
|
LIMIT 10 OFFSET {pag*10}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var ret = Singleton.Context.Database.SqlQuery<PropiedadesAdmin>(sqlq);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CuantasPaginas(int estado = 0) {
|
||||||
|
var con = Context;
|
||||||
|
double inter;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (estado == 0){
|
||||||
|
inter = con.Propiedades.Count()/10.0;
|
||||||
|
} else {
|
||||||
|
inter = con.Propiedades.Where(x=>x.Idestado == estado).Count();
|
||||||
|
}
|
||||||
|
if (inter == 0.00) return 0;
|
||||||
|
ret = (int)Math.Ceiling(inter);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CuantasPaginasBusqueda(int habitaciones, string servicios, int tipoPropiedad, int estado) {
|
||||||
|
int registrosPorPagina = 10;
|
||||||
|
|
||||||
|
var query = Context.Propiedades
|
||||||
|
.Include(p => p.IdestadoNavigation)
|
||||||
|
.Include(p => p.IdtipropiedadNavigation)
|
||||||
|
.Include(p => p.IdServicios)
|
||||||
|
.AsQueryable();
|
||||||
|
|
||||||
|
if (habitaciones > 0) {
|
||||||
|
query = query.Where(p => p.Canthabitaciones == habitaciones);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (estado > 0){
|
||||||
|
query = query.Where(x=>x.Idestado == estado);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tipoPropiedad > 0) {
|
||||||
|
query = query.Where(p => p.Idtipropiedad == tipoPropiedad);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(servicios)) {
|
||||||
|
var listaServicios = servicios.Split(',').Select(s => s.Trim()).ToList();
|
||||||
|
query = query.Where(p =>
|
||||||
|
p.IdServicios.Any(sp =>
|
||||||
|
listaServicios.Contains(sp.Descripcion)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalRegistros = query.Distinct().Count();
|
||||||
|
|
||||||
|
return (int)Math.Ceiling((double)totalRegistros / registrosPorPagina);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,9 +25,19 @@ public class RepositorioPropietario: RepositorioBase<RepositorioPropietario> {
|
|||||||
|
|
||||||
public Cliente? ObtenerPropietarioPorEmail(string email){
|
public Cliente? ObtenerPropietarioPorEmail(string email){
|
||||||
var con = Context;
|
var con = Context;
|
||||||
Cliente? cli = con.Clientes.FirstOrDefault(x=>x.Email == email);
|
Cliente? cli = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Email == email);
|
||||||
if (cli == null|| cli.Dni == 0) return null;
|
if (cli == null|| cli.Dni == 0) return null;
|
||||||
if (cli.Dni == 0 || cli == null) return null;
|
var grupo = cli.Idgrupos.FirstOrDefault(x=>x.Id == 1);
|
||||||
|
if (grupo == null) return null;
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cliente? ObtenerPropietarioPorIdPropiedad(int idpropiedad) {
|
||||||
|
var con = Context;
|
||||||
|
Propiedade? pro = con.Propiedades.Include(x=>x.DnipropietarioNavigation)
|
||||||
|
.FirstOrDefault(x=>x.Id == idpropiedad);
|
||||||
|
if (pro == null || pro.DnipropietarioNavigation == null) return null;
|
||||||
|
|
||||||
|
return pro.DnipropietarioNavigation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
|||||||
|
|
||||||
Grupo? grupo;
|
Grupo? grupo;
|
||||||
//check por si la cuenta ya existe (puede ser propietario)
|
//check por si la cuenta ya existe (puede ser propietario)
|
||||||
Cliente? cli2 = con.Clientes.Find(cli.Dni);
|
Cliente? cli2 = con.Clientes.FirstOrDefault(x=>x.Email == cli.Email);
|
||||||
if (cli2 != null) {
|
if (cli2 != null) {
|
||||||
grupo = con.Grupos.Find(2);
|
grupo = con.Grupos.Find(2);
|
||||||
if (grupo == null || grupo.Id == 0) return false;
|
if (grupo == null || grupo.Id == 0) return false;
|
||||||
@@ -88,10 +88,6 @@ public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
|||||||
var usu = Context.Clientes.FirstOrDefault(x => x.Email == email);
|
var usu = Context.Clientes.FirstOrDefault(x => x.Email == email);
|
||||||
if (usu == null) return false;
|
if (usu == null) return false;
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
//Console.WriteLine(token + "\n" +usu.Token);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return usu.Token == token;
|
return usu.Token == token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,4 +115,70 @@ public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Entidades.Admin.UsuarioAdmin> GetClientes(){
|
||||||
|
var con = Context;
|
||||||
|
var list = con.Clientes.ToList().Select(x => new Entidades.Admin.UsuarioAdmin {
|
||||||
|
Dni = x.Dni,
|
||||||
|
Email = x.Email,
|
||||||
|
Nombre = x.Nombre+" "+x.Apellido,
|
||||||
|
Habilitado = x.Habilitado});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AñadirClienteAGrupo(string email, string grupo) {
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
var cli = con.Clientes.Include(x => x.Idgrupos).FirstOrDefault(x => x.Email == email);
|
||||||
|
var gru = con.Grupos.FirstOrDefault(x => x.Nombre == grupo);
|
||||||
|
|
||||||
|
if (cli == null || gru == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.Idgrupos.Add(gru);
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EliminarClienteAGrupo(string email, string grupo) {
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
var cli = con.Clientes.Include(x => x.Idgrupos).FirstOrDefault(x => x.Email == email);
|
||||||
|
var gru = con.Grupos.FirstOrDefault(x => x.Nombre == grupo);
|
||||||
|
|
||||||
|
if (cli == null || gru == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cli.Idgrupos.Remove(gru);
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BajaCliente(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
Cliente? cli = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Dni == dni);
|
||||||
|
if (cli == null) return false;
|
||||||
|
|
||||||
|
if (cli.Habilitado == 0) {
|
||||||
|
cli.Habilitado = 1;
|
||||||
|
} else {
|
||||||
|
cli.Habilitado = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cliente? ObtenerClientePorDni(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
Cliente? cli = con.Clientes.FirstOrDefault(x=>x.Dni == dni);
|
||||||
|
return cli;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cliente? ObtenerClientePorToken(string token) {
|
||||||
|
var con = Context;
|
||||||
|
Cliente? cli = con.Clientes.Include(x=>x.NotificacioneDniclienteNavigations).FirstOrDefault(x=>x.Token == token);
|
||||||
|
|
||||||
|
if (cli == null|| cli.Dni == 0) return null;
|
||||||
|
return cli;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user