Compare commits
14 Commits
acciones_a
...
FuncionesP
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a26fe8bd1 | |||
| dee2031d87 | |||
| 5289c07d84 | |||
| 646cf3e009 | |||
| c116c924cd | |||
| 28cf77ad18 | |||
| 00cce75fad | |||
| 29f7dc4efe | |||
| e9b3baa9ca | |||
| aa36454730 | |||
| 50bb59e15f | |||
| d2a7368dee | |||
| feb4db86c0 | |||
| 80c778d91a |
@@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlquilaFacil", "AlquilaFacil.csproj", "{76BA8B31-BAD3-49CD-B8B8-BE22D8AEA281}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{76BA8B31-BAD3-49CD-B8B8-BE22D8AEA281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{76BA8B31-BAD3-49CD-B8B8-BE22D8AEA281}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{76BA8B31-BAD3-49CD-B8B8-BE22D8AEA281}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{76BA8B31-BAD3-49CD-B8B8-BE22D8AEA281}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CF93AFAC-32EF-4993-84A2-CA2EB32F58FF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,24 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using System.Text.Json;
|
||||
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AccionesController: ControllerBase {
|
||||
|
||||
//Reutilizo el loginDto pero no lleno el campo de contraseña
|
||||
[HttpPost("api/acciones")]
|
||||
public IActionResult ListarAccionesPorUsuario([FromBody] LoginDto email, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (email.Email == "" || email.Email == null) return BadRequest();
|
||||
[HttpGet("api/acciones")]
|
||||
public IActionResult ListarAccionesPorUsuario([FromHeader(Name ="Email")] string Email, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (Email == "" || Email == null) return BadRequest();
|
||||
|
||||
if (Auth == "") return Unauthorized(new { esValido = false});
|
||||
|
||||
bool esValido = RepositorioUsuarios.Singleton.CheckToken(email.Email, Auth);
|
||||
bool esValido = RepositorioUsuarios.Singleton.CheckToken(Email, Auth);
|
||||
if (!esValido) return Unauthorized();
|
||||
|
||||
var Permisos = RepositorioPermisos.Singleton.ListarPermisos(email.Email);
|
||||
var Permisos = RepositorioPermisos.Singleton.ListarPermisos(Email);
|
||||
Response.Headers["Content-Type"] = "application/json";
|
||||
return Ok(Permisos);
|
||||
}
|
||||
|
||||
[HttpPost("api/acciones/grupo")]
|
||||
public IActionResult ListarAccionesPorGrupo([FromHeader(Name = "Auth")] string Auth,
|
||||
[FromBody] AccionesPorGrupoDto req) {
|
||||
if (string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
bool esValido = RepositorioUsuarios.Singleton.CheckToken(req.Email, Auth);
|
||||
if (esValido == false) return BadRequest(esValido);
|
||||
|
||||
bool tieneGrupo = RepositorioUsuarios.Singleton.CheckGrupo(req.Email, req.Grupo);
|
||||
if (tieneGrupo == false) return Unauthorized();
|
||||
|
||||
var permisos = RepositorioGrupos.Singleton.ListarPermisosDeGrupo(req.Grupo);
|
||||
return Ok(permisos);
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,6 @@ public class GruposController: ControllerBase {
|
||||
bool ret = RepositorioGrupos.Singleton.CrearGrupo(grupo.descripcion);
|
||||
return (ret) ? Ok(ret) : BadRequest();
|
||||
}
|
||||
|
||||
[HttpGet("api/admin/grupos")]
|
||||
public IActionResult ListarGrupo(){
|
||||
return Ok(RepositorioGrupos.Singleton.Listar());
|
||||
}
|
||||
}
|
||||
|
||||
public record AdminGrupo(string descripcion);
|
||||
|
||||
@@ -26,13 +26,13 @@ public class InquilinoController: ControllerBase
|
||||
|
||||
[HttpPost("api/inquilino")]
|
||||
public IActionResult Post([FromBody] CrearClienteDto cid, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (!string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
if (string.IsNullOrEmpty(Auth)) return BadRequest(new {message = "El String Auth Esta Vacio"});
|
||||
var ret3 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 4);
|
||||
if (ret3 == false) return BadRequest(ret3);
|
||||
if (ret3 == false) return BadRequest(new {message = "Falló el permiso"});
|
||||
|
||||
|
||||
var ret = verificarCrearUsuario(cid);
|
||||
if (ret != "") return BadRequest(ret);
|
||||
if (ret != "") return BadRequest(new {message = ret});
|
||||
|
||||
var cli = new Cliente {
|
||||
Dni = cid.dni,
|
||||
@@ -45,7 +45,7 @@ public class InquilinoController: ControllerBase
|
||||
};
|
||||
|
||||
bool ret2 = RepositorioUsuarios.Singleton.AltaInquilino(cli);
|
||||
return (ret2) ? Ok() : BadRequest(ret);
|
||||
return (ret2) ? Ok(new {message = "Se dio de alta la cuenta"}) : BadRequest(new {message = "Fallo Dar de Alta El inquilino"});
|
||||
}
|
||||
|
||||
private string verificarCrearUsuario(CrearClienteDto cid) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
|
||||
@@ -24,27 +23,42 @@ public class PropiedadesController: ControllerBase {
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (Id < 0) return BadRequest("la id de propiedad no puede ser negativa");
|
||||
if (Id < 0) return BadRequest(new {message ="la id de propiedad no puede ser negativa"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(Id);
|
||||
if (ret == null) return BadRequest("No existe la propiedad");
|
||||
if (ret == null) return BadRequest(new {message ="No existe la propiedad"});
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedades/Propietario")]
|
||||
public IActionResult ObtenerPropiedadesPorPropietario (
|
||||
[FromBody] string email,
|
||||
[FromHeader(Name = "Email")] string email,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
email = email.Trim();
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest("falta campo email");
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new {message ="falta campo email"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
||||
IQueryable<PropiedadesDto> ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedades/Propietario/Bajas")]
|
||||
public IActionResult ObtenerPropiedadesPorPropietarioBajas (
|
||||
[FromHeader(Name = "Email")] string email,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
email = email.Trim();
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new {message ="falta campo email"});
|
||||
|
||||
IQueryable<PropiedadesDto> ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesDeBajaPorEmail(email);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
@@ -58,71 +72,105 @@ public class PropiedadesController: ControllerBase {
|
||||
if (validacion2 != "") return BadRequest(new { message = validacion2 });
|
||||
|
||||
Cliente? cli = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(propiedad.Email);
|
||||
if (cli == null) return BadRequest("El email no corresponde a un propietario");
|
||||
if (cli == null) return BadRequest(new { message = "El email no corresponde a un propietario"});
|
||||
|
||||
Propiedade Prop = new Propiedade{
|
||||
Canthabitaciones = propiedad.Canthabitaciones,
|
||||
Dnipropietario = cli.Dni,
|
||||
Idtipropiedad = propiedad.Idtipropiedad,
|
||||
Ubicacion = propiedad.Ubicacion,
|
||||
Letra = propiedad.Letra != null ? propiedad.Letra : null,
|
||||
Piso = propiedad.Piso != null ? propiedad.Piso : null,
|
||||
Letra = propiedad.Letra ?? null,
|
||||
Piso = propiedad.Piso ?? null,
|
||||
};
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop);
|
||||
return (ret)?
|
||||
Ok("Fue Cargado Correctamente") :
|
||||
BadRequest("Fallo al momento de añadir la propiedad a la base de datos");
|
||||
Ok(new { message = "Fue Cargado Correctamente"}) :
|
||||
BadRequest(new { message = "Fallo al momento de añadir la propiedad a la base de datos"});
|
||||
}
|
||||
|
||||
[HttpPatch("api/propiedad")]
|
||||
public IActionResult PatchPropiedad([FromBody] PatchPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth) {
|
||||
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
string validacion2 = ValidarPropiedad(propiedad);
|
||||
if (validacion2 != "") return BadRequest(new { message = validacion2 });
|
||||
|
||||
Cliente? cli = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(propiedad.Email);
|
||||
if (cli == null) return BadRequest(new { message = "El email no corresponde a un propietario"});
|
||||
|
||||
List<Servicio> servs = RepositorioServicios.Singleton.ObtenerServiciosPorDescripcion(propiedad.Servicios);
|
||||
|
||||
Propiedade Prop = new Propiedade{
|
||||
Id = propiedad.id,
|
||||
Canthabitaciones = propiedad.Canthabitaciones,
|
||||
Dnipropietario = cli.Dni,
|
||||
Idtipropiedad = propiedad.tipo,
|
||||
Ubicacion = propiedad.Ubicacion,
|
||||
Letra = propiedad.Letra ?? null,
|
||||
Piso = propiedad.Piso ?? null,
|
||||
IdServicios = servs,
|
||||
};
|
||||
|
||||
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop);
|
||||
return (ret)?
|
||||
Ok(new {message = "Fue modificado Correctamente"}):
|
||||
BadRequest(new {message = "Fallo al modificar la base de datos"});
|
||||
}
|
||||
|
||||
[HttpDelete("api/propiedad")]
|
||||
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth){
|
||||
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth, [FromHeader(Name = "Email")] string email){
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (id <= 0) return BadRequest("No es una id valida");
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new { message = "Fallo al identificarse el usuario"});
|
||||
if (id <= 0) return BadRequest(new { message = "No es una id valida"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id);
|
||||
Cliente? propie = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(email);
|
||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id, propie);
|
||||
|
||||
return ret ?
|
||||
Ok(new {message = $"la propiedad con id {id} fue dada de baja"}):
|
||||
BadRequest("Fallo al dar de baja la propiedad");
|
||||
Ok(new { message = $"Se Cambio el estado de la propiedad con id {id}"}):
|
||||
BadRequest(new {message="Fallo al cambiar el estado de la propiedad"});
|
||||
}
|
||||
|
||||
[HttpPut("api/propiedades/addServicio")]
|
||||
public IActionResult AñadirServicio([FromBody] ServicioAPropiedadDto Servicios, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (Servicios.propiedadid <= 0) return BadRequest("No puede tener una id negativa o cero");
|
||||
if (Servicios.idServicios.Count() < 1) return BadRequest("Falta añadir servicios");
|
||||
if (Servicios.idServicios.Any(x => x<= 0)) return BadRequest("No tienen haber ids negativas o cero de servicio");
|
||||
if (Servicios.propiedadid <= 0) return BadRequest(new {message ="No puede tener una id negativa o cero"});
|
||||
if (Servicios.idServicios.Count() < 1) return BadRequest(new {message ="Falta añadir servicios"});
|
||||
if (Servicios.idServicios.Any(x => x<= 0)) return BadRequest(new {message ="No tienen haber ids negativas o cero de servicio"});
|
||||
|
||||
var serv = RepositorioServicios.Singleton.ObtenerServiciosPorPropiedad(Servicios.propiedadid);
|
||||
|
||||
bool validacion2 = Servicios.idServicios.Any(x => serv.Contains(x));
|
||||
|
||||
if (validacion2 == true) return BadRequest("Hay elementos repetidos");
|
||||
if (validacion2 == true) return BadRequest(new {message ="Hay elementos repetidos"});
|
||||
|
||||
bool ret = RepositorioPropiedades.
|
||||
Singleton.AñadirServicioAPropiedad(Servicios.propiedadid, Servicios.idServicios);
|
||||
|
||||
return ret ?
|
||||
Ok("Los Servicios Se Cargaron correctamente a la propiedad") : BadRequest("No se pudo Cargar los Servicios a la propiedad");
|
||||
Ok(new {message ="Los Servicios Se Cargaron correctamente a la propiedad"}) : BadRequest(new {message ="No se pudo Cargar los Servicios a la propiedad"});
|
||||
|
||||
}
|
||||
|
||||
[HttpPut("api/propiedades/RmServicio")]
|
||||
public IActionResult EliminarServicio([FromBody] ServicioAPropiedadDto servicio, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (servicio.propiedadid <= 0) return BadRequest("No puede tener una id negativa o cero");
|
||||
if (servicio.idServicios.Count() < 1) return BadRequest("Falta añadir servicios");
|
||||
if (servicio.idServicios.Any(x => x<= 0)) return BadRequest("No tienen haber ids negativas o cero de servicio");
|
||||
if (servicio.propiedadid <= 0) return BadRequest(new {message ="No puede tener una id negativa o cero"});
|
||||
if (servicio.idServicios.Count() < 1) return BadRequest(new {message ="Falta añadir servicios"});
|
||||
if (servicio.idServicios.Any(x => x<= 0)) return BadRequest(new {message ="No tienen haber ids negativas o cero de servicio"});
|
||||
|
||||
var serv = RepositorioServicios.Singleton.ObtenerServiciosPorPropiedad(servicio.propiedadid);
|
||||
|
||||
@@ -131,7 +179,7 @@ public class PropiedadesController: ControllerBase {
|
||||
bool ret = RepositorioPropiedades.Singleton.BajaServiciosAPropiedad(servicio.propiedadid, servicio.idServicios);
|
||||
|
||||
return ret ?
|
||||
Ok("Se Eliminaron los servicios seleccionados de la propiedad") : BadRequest("Fallo al eliminarse los servicios de la propiedad");
|
||||
Ok(new {message ="Se Eliminaron los servicios seleccionados de la propiedad"}) : BadRequest(new {message ="Fallo al eliminarse los servicios de la propiedad"});
|
||||
|
||||
}
|
||||
|
||||
@@ -140,11 +188,32 @@ public class PropiedadesController: ControllerBase {
|
||||
|
||||
string ret = "";
|
||||
if (String.IsNullOrEmpty(prop.Email)) ret += "Falta Definir un email de propietario\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 (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
}
|
||||
private string ValidarPropiedad(PatchPropiedadDto prop) {
|
||||
if (prop == null) return "Esta mal formado el body de la request";
|
||||
|
||||
string ret = "";
|
||||
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 (prop.id <1 ) ret += "No puede haber una id menor a 1";
|
||||
|
||||
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 (String.IsNullOrEmpty(prop.Ubicacion)) ret += "Tiene que definir la ubicacion de la propiedad\n";
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PropietarioController: ControllerBase {
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost("api/propietarios")]
|
||||
[HttpPost("api/propietario")]
|
||||
public IActionResult AltaPropietario([FromBody]CrearClienteDto Propietario,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
|
||||
2
Entidades/Dto/AccionesDeGrupo.cs
Normal file
2
Entidades/Dto/AccionesDeGrupo.cs
Normal file
@@ -0,0 +1,2 @@
|
||||
namespace Entidades.Dto;
|
||||
public record AccionesPorGrupoDto(string Email, string Grupo);
|
||||
3
Entidades/Dto/PatchPropiedadDto.cs
Normal file
3
Entidades/Dto/PatchPropiedadDto.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Entidades.Dto;
|
||||
|
||||
public record PatchPropiedadDto(int id, string Ubicacion, int Canthabitaciones, int? Piso, string? Letra, string Email, int tipo, List<string> Servicios);
|
||||
@@ -3,7 +3,8 @@ public class PropiedadesDto {
|
||||
public int id { get; set; }
|
||||
public string Ubicacion { get; set; } = "";
|
||||
public int canthabitaciones { get; set; }
|
||||
public string piso { get; set; } = "";
|
||||
public int piso { get; set; }
|
||||
public string letra { get; set; } = "";
|
||||
public string TipoPropiedad { get; set; } = "";
|
||||
}
|
||||
public string Tipo { get; set; } = "";
|
||||
public string? Servicios {get;set;} = "";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Entidades;
|
||||
|
||||
@@ -9,6 +10,7 @@ public partial class Grupo
|
||||
|
||||
public string Nombre { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<Cliente> Idclientes { get; set; } = new List<Cliente>();
|
||||
|
||||
public virtual ICollection<Permiso> Idpermisos { get; set; } = new List<Permiso>();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<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"/>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB |
4
Front/public/favicon.svg
Normal file
4
Front/public/favicon.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" class="size-6">
|
||||
<path fill-rule="evenodd" d="M4.125 3C3.089 3 2.25 3.84 2.25 4.875V18a3 3 0 0 0 3 3h15a3 3 0 0 1-3-3V4.875C17.25 3.839 16.41 3 15.375 3H4.125ZM12 9.75a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5H12Zm-.75-2.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 0 1.5H12a.75.75 0 0 1-.75-.75ZM6 12.75a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5H6Zm-.75 3.75a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H6a.75.75 0 0 1-.75-.75ZM6 6.75a.75.75 0 0 0-.75.75v3c0 .414.336.75.75.75h3a.75.75 0 0 0 .75-.75v-3A.75.75 0 0 0 9 6.75H6Z" clip-rule="evenodd" />
|
||||
<path d="M18.75 6.75h1.875c.621 0 1.125.504 1.125 1.125V18a1.5 1.5 0 0 1-3 0V6.75Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 715 B |
@@ -1,33 +1,76 @@
|
||||
<script lang="ts">
|
||||
import Login from "./login/loginPage.svelte";
|
||||
import Login from "./paginas/login.svelte";
|
||||
import { Router, Route, link } from 'svelte-routing';
|
||||
import MenuPage from './Menu/page.svelte';
|
||||
import ProteRoute from './lib/RutaProtegida.svelte';
|
||||
import InfoPage from './Info/page.svelte';
|
||||
import InqPage from "./Inquilino/page.svelte";
|
||||
import PropPage from "./Propietario/page.svelte";
|
||||
import MenuPage from './paginas/menu.svelte';
|
||||
import ProteRoute from './Componentes/RutaProtegida.svelte';
|
||||
import InfoPage from './paginas/info.svelte';
|
||||
import InqPage from "./paginas/inquilino.svelte";
|
||||
import PropPage from "./paginas/propietario.svelte";
|
||||
import MisPropiedades from "./paginas/MisPropiedades.svelte";
|
||||
import MisPropiedadesDeBaja from "./paginas/MisPropiedadesDeBaja.svelte";
|
||||
import FrontAdmin from "./paginas/grupos/AdminG.svelte";
|
||||
import FrontInformes from "./paginas/grupos/InformesG.svelte";
|
||||
import FrontInquilino from "./paginas/grupos/InquilinoG.svelte";
|
||||
import FrontPropietario from "./paginas/grupos/PropietarioG.svelte";
|
||||
import PublicarPropiedad from "./paginas/PublicarPropiedad.svelte";
|
||||
</script>
|
||||
|
||||
<Router>
|
||||
|
||||
<!-- Plantilla path
|
||||
<Route path="">
|
||||
<ProteRoute componente={}/>
|
||||
</Route>
|
||||
-->
|
||||
|
||||
<Route path="/" component={Login} />
|
||||
<Route path="/Info" component={InfoPage} />
|
||||
|
||||
<Route path="/inqtest" component={InqPage} />
|
||||
|
||||
|
||||
<Route path="/Menu">
|
||||
<ProteRoute componente={MenuPage} />
|
||||
</Route>
|
||||
|
||||
<!--Publicar Propiedad-->
|
||||
<Route path="/accion/1">
|
||||
<ProteRoute componente={PublicarPropiedad}/>
|
||||
</Route>
|
||||
|
||||
<!--Mis Propiedades-->
|
||||
<Route path="/accion/2">
|
||||
<ProteRoute componente={MisPropiedades}/>
|
||||
</Route>
|
||||
|
||||
<!--Crear Cuenta Inquilino-->
|
||||
<Route path="/accion/4">
|
||||
<ProteRoute componente={InqPage}/>
|
||||
</Route>
|
||||
|
||||
|
||||
<!--Crear Cuenta Propietario-->
|
||||
<Route path="/accion/5">
|
||||
<ProteRoute componente={PropPage}/>
|
||||
</Route>
|
||||
|
||||
<!--Crear Cuenta Propietario-->
|
||||
<Route path="/accion/8">
|
||||
<ProteRoute componente={MisPropiedadesDeBaja}/>
|
||||
</Route>
|
||||
|
||||
<!--Paginas info Grupo-->
|
||||
<Route path="/grupo/Inquilino">
|
||||
<ProteRoute componente={FrontInquilino}/>
|
||||
</Route>
|
||||
<Route path="/grupo/Propietario">
|
||||
<ProteRoute componente={FrontPropietario}/>
|
||||
</Route>
|
||||
<Route path="/grupo/Admin">
|
||||
<ProteRoute componente={FrontAdmin}/>
|
||||
</Route>
|
||||
<Route path="/grupo/Informes">
|
||||
<ProteRoute componente={FrontInformes}/>
|
||||
</Route>
|
||||
|
||||
|
||||
|
||||
</Router>
|
||||
|
||||
|
||||
@@ -18,16 +18,24 @@
|
||||
let domicilio: string = $state("")
|
||||
let celular: string = $state("")
|
||||
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
async function submitForm(event: any) {
|
||||
event.preventDefault();
|
||||
try {
|
||||
let response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
'Content-Type' : 'application/json',
|
||||
},
|
||||
body: JSON.stringify({dni, nombre, apellido, domicilio, celular, email, contraseña})
|
||||
});
|
||||
if (response.ok){
|
||||
const errorData = await response.json();
|
||||
errorMessage = errorData.message;
|
||||
showAlert = true;
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
errorMessage = errorData.message;
|
||||
48
Front/src/Componentes/ListaAcciones.svelte
Normal file
48
Front/src/Componentes/ListaAcciones.svelte
Normal file
@@ -0,0 +1,48 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
type Permiso = {
|
||||
id: number;
|
||||
descripcion: string;
|
||||
};
|
||||
|
||||
let permisos = writable<Permiso[]>([]);
|
||||
|
||||
onMount(()=> {
|
||||
HandlePermisos();
|
||||
});
|
||||
|
||||
const email = localStorage.getItem("email");
|
||||
const path = location.pathname;
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
async function HandlePermisos() {
|
||||
const match = path.match(/\/grupo\/(.+)/);
|
||||
const grupo = match ? match[1] : null;
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/acciones/grupo",{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
'Content-Type' : "application/json"
|
||||
},
|
||||
body: JSON.stringify({email, grupo}),
|
||||
});
|
||||
if (response.ok) {
|
||||
const json = await response.json();
|
||||
permisos.set(json);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="list-group" style="border: 1px solid black">
|
||||
{#each $permisos as item}
|
||||
<a href="/accion/{item.id}" class="list-group-item list-group-item-action">
|
||||
{item.descripcion}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
18
Front/src/Componentes/ModalEstatico.svelte
Normal file
18
Front/src/Componentes/ModalEstatico.svelte
Normal file
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '@sveltestrap/sveltestrap';
|
||||
|
||||
const toggle = () => (open = !open);
|
||||
let {payload, close = toggle, iscomponent = false } = $props();
|
||||
let open = $state(true);
|
||||
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<Modal body isOpen={open} toggle={close}>
|
||||
{#if iscomponent == false}
|
||||
{payload}
|
||||
{:else}
|
||||
{@render payload()}
|
||||
{/if}
|
||||
</Modal>
|
||||
</div>
|
||||
74
Front/src/Componentes/NavBarAutocompletable.svelte
Normal file
74
Front/src/Componentes/NavBarAutocompletable.svelte
Normal file
@@ -0,0 +1,74 @@
|
||||
<script lang="ts">
|
||||
import { Navbar, NavbarBrand, NavbarToggler, Nav, Collapse } from "@sveltestrap/sveltestrap";
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from 'svelte/store';
|
||||
import './css/popup.css';
|
||||
import type { Grupo } from "../types";
|
||||
let isOpen: boolean = $state(false);
|
||||
|
||||
const permisos = writable<Grupo[]>([]);
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
async function obtenerPermisos(){
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/acciones",{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
'Email' : String(email),
|
||||
'Content-Type' : "application/json"
|
||||
},
|
||||
});
|
||||
if (response.ok){
|
||||
const json = await response.json();
|
||||
|
||||
permisos.set(json);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
onMount( () => {
|
||||
obtenerPermisos();
|
||||
})
|
||||
|
||||
function redirijir(path: string){
|
||||
location.replace(path);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<Navbar container="xxl" expand="md" color="dark-subtle">
|
||||
<NavbarBrand href="/">
|
||||
AlquilaFacil
|
||||
</NavbarBrand>
|
||||
<div class="badge">
|
||||
<a href="/Menu">
|
||||
<img src="/home.svg" alt="Volver al Menú"/>
|
||||
</a>
|
||||
</div>
|
||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||
<Collapse isOpen={isOpen} navbar expand="md">
|
||||
<Nav class="ms-auto" navbar>
|
||||
{#each $permisos as item }
|
||||
<div class="dropdown">
|
||||
<div class="btn-group" style="margin-left: 3px; margin-top: 3px">
|
||||
<button class="btn btn-secondary" onclick={() => redirijir("/grupo/"+item.nombre)} >{item.nombre}</button>
|
||||
<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>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" >
|
||||
{#each item.idpermisos as perm}
|
||||
<a class="dropdown-item link-underline-opacity-0 link-underline" href="/accion/{perm.id}">{perm.descripcion}</a>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</Nav>
|
||||
</Collapse>
|
||||
</Navbar>
|
||||
61
Front/src/Componentes/RowPropiedad.svelte
Normal file
61
Front/src/Componentes/RowPropiedad.svelte
Normal file
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { fade } from "svelte/transition";
|
||||
import ModalEstatico from "./ModalEstatico.svelte";
|
||||
import ModificarPropiedadForm from "./modificarPropiedadForm.svelte";
|
||||
|
||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
||||
|
||||
let modal: boolean = $state(false);
|
||||
let modalpayload: string = $state("");
|
||||
|
||||
let modificar: boolean = $state(false);
|
||||
|
||||
function setmod(){
|
||||
modificar = !modificar;
|
||||
}
|
||||
|
||||
async function BajaPropiedad(){
|
||||
modal = false;
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
||||
method: "DELETE",
|
||||
headers:{
|
||||
'Auth' : String(sessionStorage.getItem("token")),
|
||||
'Email' : String(localStorage.getItem("email"))
|
||||
},
|
||||
});
|
||||
|
||||
const json = await responce.json();
|
||||
modalpayload = json.message;
|
||||
modal = true;
|
||||
location.reload();
|
||||
}catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr in:fade>
|
||||
<td>{id}</td>
|
||||
<td>{ubicacion}</td>
|
||||
<td>{canthabitaciones}</td>
|
||||
<td>{letra}</td>
|
||||
<td>{piso}</td>
|
||||
<td>{tipo}</td>
|
||||
<td>{servicios}</td>
|
||||
<td class="text-end">
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
{#if modal}
|
||||
<ModalEstatico payload={modalpayload}/>
|
||||
{/if}
|
||||
{#if modificar}
|
||||
<tr transition:fade={{duration:100}}>
|
||||
<td colspan="8">
|
||||
<ModificarPropiedadForm {id} {ubicacion} {canthabitaciones} {letra} {piso} {tipo} {servicios}/>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
48
Front/src/Componentes/css/popup.css
Normal file
48
Front/src/Componentes/css/popup.css
Normal file
@@ -0,0 +1,48 @@
|
||||
@keyframes rollDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: rotateX(-90deg);
|
||||
transform-origin: top;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: rotateX(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rollUp {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: rotateX(0deg);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: rotateX(-90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
display: none;
|
||||
animation: none;
|
||||
transform-origin: top;
|
||||
}
|
||||
|
||||
.dropdown-menu.show {
|
||||
animation: rollDown 0.5s ease forwards;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.popup.show {
|
||||
animation: rollDown 0.5s ease forwards;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdown-menu.hide {
|
||||
animation: rollUp 0.5s ease forwards;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.popup.hide {
|
||||
animation: rollUp 0.5s ease forwards;
|
||||
display: block;
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
let email = $state("")
|
||||
let contraseña = $state("")
|
||||
let errorMessage = $state("")
|
||||
let showAlert = false;
|
||||
|
||||
// @ts-ignore
|
||||
async function submitForm(event) {
|
||||
@@ -25,7 +24,6 @@
|
||||
if (!response.ok){
|
||||
const errorData = await response.json()
|
||||
errorMessage = errorData.message;
|
||||
showAlert = true;
|
||||
return;
|
||||
}
|
||||
|
||||
161
Front/src/Componentes/modificarPropiedadForm.svelte
Normal file
161
Front/src/Componentes/modificarPropiedadForm.svelte
Normal file
@@ -0,0 +1,161 @@
|
||||
<script lang="ts">
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let { canthabitaciones, id, letra, piso, tipo, ubicacion, servicios } = $props();
|
||||
let serviciosSeleccionados: string[] = $state([]);
|
||||
const serviciosDisponibles = ["Gas", "Internet", "Telefono", "Luz"];
|
||||
|
||||
onMount(() => {
|
||||
switch (tipo) {
|
||||
case "Casa":
|
||||
tipo = "1";
|
||||
break;
|
||||
case "Piso":
|
||||
tipo = "2";
|
||||
break;
|
||||
case "Departamento":
|
||||
tipo = "3";
|
||||
break;
|
||||
case "Galpon":
|
||||
tipo = "4";
|
||||
break;
|
||||
case "LocalComercial":
|
||||
tipo = "5";
|
||||
break;
|
||||
case "Oficina":
|
||||
tipo = "6";
|
||||
break;
|
||||
}
|
||||
serviciosSeleccionados = servicios.split(", ");
|
||||
});
|
||||
|
||||
let showAlert: boolean = $state(false);
|
||||
let errorMessage: string = $state("");
|
||||
const token = sessionStorage.getItem("token");
|
||||
const email = localStorage.getItem("email");
|
||||
|
||||
async function submitForm(e: Event) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
let response = await fetch(String($urlG + "/api/propiedad"), {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Auth: String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id,
|
||||
canthabitaciones,
|
||||
letra,
|
||||
piso,
|
||||
tipo,
|
||||
ubicacion,
|
||||
email,
|
||||
servicios: serviciosSeleccionados,
|
||||
}),
|
||||
});
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
errorMessage = errorData.message;
|
||||
showAlert = true;
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error("Fallo al enviar el formulario para crear un inquilino");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if showAlert}
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<strong>{errorMessage}</strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close close"
|
||||
aria-label="Close"
|
||||
data-bs-dismiss="alert"
|
||||
></button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<form onsubmit={submitForm} class="card card-body">
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
id="ubicacion"
|
||||
class="form-control"
|
||||
bind:value={ubicacion}
|
||||
placeholder="Ubicación"
|
||||
required
|
||||
/>
|
||||
<label for="ubicacion">Ubicación</label>
|
||||
</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="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="piso"
|
||||
class="form-control"
|
||||
bind:value={piso}
|
||||
min="0"
|
||||
placeholder="Piso"
|
||||
/>
|
||||
<label for="piso">Piso</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
id="letra"
|
||||
class="form-control"
|
||||
bind:value={letra}
|
||||
maxlength="1"
|
||||
placeholder="Letra"
|
||||
/>
|
||||
<label for="letra">Letra</label>
|
||||
</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>
|
||||
|
||||
<div class="mb-3">
|
||||
<h6 class="form-floating form-label">Servicios</h6>
|
||||
{#each serviciosDisponibles as servicio}
|
||||
<div class="form-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-check-input"
|
||||
bind:group={serviciosSeleccionados}
|
||||
value={servicio}
|
||||
id={`servicio-${servicio}`}
|
||||
/>
|
||||
<label class="form-check-label" for={`servicio-${servicio}`}>
|
||||
{servicio}
|
||||
</label>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Enviar</button>
|
||||
</form>
|
||||
@@ -1,6 +0,0 @@
|
||||
<script>
|
||||
import NavBarAuto from "../lib/NavBarAutocompletable.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAuto/>
|
||||
hol
|
||||
@@ -1,64 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
let isOpen: boolean = $state(false);
|
||||
|
||||
interface Permiso {
|
||||
id: number;
|
||||
descripcion: string;
|
||||
}
|
||||
|
||||
const permisos = writable<Permiso[]>([]);
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
|
||||
async function obtenerPermisos(){
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/acciones",{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
'Content-Type' : "application/json"
|
||||
},
|
||||
body: JSON.stringify({email})
|
||||
});
|
||||
if (response.ok){
|
||||
const json = await response.json();
|
||||
|
||||
permisos.set(json);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$inspect(permisos);
|
||||
onMount( () => {
|
||||
obtenerPermisos();
|
||||
})
|
||||
</script>
|
||||
|
||||
<Navbar container="xxl" expand="md" color="dark-subtle">
|
||||
<NavbarBrand href="/">
|
||||
AlquilaFacil
|
||||
</NavbarBrand>
|
||||
<div class="card">
|
||||
<a href="/Menu">
|
||||
<img src="/home.svg" alt="Volver al Menú"/>
|
||||
</a>
|
||||
</div>
|
||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||
<Collapse isOpen={isOpen} navbar expand="md">
|
||||
<Nav class="ms-auto" navbar>
|
||||
{#each $permisos as item }
|
||||
<NavItem>
|
||||
<NavLink href="/accion/{item.id}">{item.descripcion}</NavLink>
|
||||
</NavItem>
|
||||
{/each}
|
||||
</Nav>
|
||||
</Collapse>
|
||||
</Navbar>
|
||||
@@ -1,10 +0,0 @@
|
||||
<script lang="ts">
|
||||
import Login from "../lib/login.svelte"
|
||||
import Navbar from "../lib/NavBarLogin.svelte";
|
||||
</script>
|
||||
|
||||
<Navbar/>
|
||||
<div class="position-relative">
|
||||
<br>
|
||||
<Login/>
|
||||
</div>
|
||||
64
Front/src/paginas/MisPropiedades.svelte
Normal file
64
Front/src/paginas/MisPropiedades.svelte
Normal file
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte" ;
|
||||
import { writable } from 'svelte/store';
|
||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||
import type { PropiedadDto } from "../types";
|
||||
|
||||
let propiedades = writable<PropiedadDto[]>([]);
|
||||
let email = localStorage.getItem("email");
|
||||
let token = sessionStorage.getItem("token");
|
||||
|
||||
let fallo: boolean = $state(false);
|
||||
|
||||
onMount(async ()=> {
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
'Email' : String(email),
|
||||
'Content-Type' : "application/json"
|
||||
},
|
||||
});
|
||||
if (responce.ok){
|
||||
const json = await responce.json();
|
||||
propiedades.set(json);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!responce.ok){
|
||||
fallo = true;
|
||||
}
|
||||
} catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<div class="container table-responsive">
|
||||
<table class="table-responsive table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>ubicacion</th>
|
||||
<th>Habitaciones</th>
|
||||
<th>Letra</th>
|
||||
<th>Piso</th>
|
||||
<th>Tipo</th>
|
||||
<th>Servicios</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#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} />
|
||||
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{#if fallo}
|
||||
<div class="container alert alert-danger">Fallo al intentar Obtener la lista de propiedades</div>
|
||||
{/if}
|
||||
64
Front/src/paginas/MisPropiedadesDeBaja.svelte
Normal file
64
Front/src/paginas/MisPropiedadesDeBaja.svelte
Normal file
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte" ;
|
||||
import { writable } from 'svelte/store';
|
||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||
import type { PropiedadDto } from "../types";
|
||||
|
||||
let propiedades = writable<PropiedadDto[]>([]);
|
||||
let email = localStorage.getItem("email");
|
||||
let token = sessionStorage.getItem("token");
|
||||
|
||||
let fallo: boolean = $state(false);
|
||||
|
||||
onMount(async ()=> {
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario/Bajas", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
'Email' : String(email),
|
||||
'Content-Type' : "application/json"
|
||||
},
|
||||
});
|
||||
if (responce.ok){
|
||||
const json = await responce.json();
|
||||
propiedades.set(json);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!responce.ok){
|
||||
fallo = true;
|
||||
}
|
||||
} catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<div class="container table-responsive">
|
||||
<table class="table-responsive table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>ubicacion</th>
|
||||
<th>Habitaciones</th>
|
||||
<th>Letra</th>
|
||||
<th>Piso</th>
|
||||
<th>Tipo</th>
|
||||
<th>Servicios</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#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"}/>
|
||||
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{#if fallo}
|
||||
<div class="container alert alert-danger">Fallo al intentar Obtener la lista de propiedades</div>
|
||||
{/if}
|
||||
129
Front/src/paginas/PublicarPropiedad.svelte
Normal file
129
Front/src/paginas/PublicarPropiedad.svelte
Normal file
@@ -0,0 +1,129 @@
|
||||
<script lang="ts">
|
||||
import { writable } from "svelte/store"; // Importar writable para los estados
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import type { Propiedad } from "../types";
|
||||
|
||||
let propiedad: Propiedad = {
|
||||
ubicacion: "",
|
||||
canthabitaciones: 1,
|
||||
piso: 0,
|
||||
letra: "",
|
||||
email: localStorage.getItem("email") || "",
|
||||
idtipropiedad: 1,
|
||||
};
|
||||
|
||||
let token = sessionStorage.getItem("token");
|
||||
let mostrarModal = $state(false);
|
||||
let datosModal = $state("");
|
||||
|
||||
const submitForm = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
mostrarModal = false;
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
'Content-Type': "application/json"
|
||||
},
|
||||
body: JSON.stringify(propiedad),
|
||||
});
|
||||
|
||||
|
||||
const json = await response.json();
|
||||
datosModal = json.message;
|
||||
mostrarModal =true;
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable />
|
||||
|
||||
|
||||
<div class="container-fluid mt-4 row">
|
||||
|
||||
<div class="col-sm">
|
||||
<BarraHorizontalConTexto text={"Formulario Alta propiedad"}/>
|
||||
Este es un formulario con el objetivo de que usted pueda registrar las propiedades <b>suyas</b> que quiera hacer visibles a las busquedas de inquilinos.
|
||||
<br><br>
|
||||
|
||||
<BarraHorizontalConTexto text={"Indicaciones"}/>
|
||||
Para poder cargar la propiedad deberá especificar su ubicacion, la cantidad de habitaciones que posée, en caso de ser un edificio el piso, y letra, y que tipo de propiedad és (casa, departamento, oficina...).
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<h2>Registrar Propiedad</h2>
|
||||
<form class="card card-body" onsubmit={submitForm}>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
id="ubicacion"
|
||||
class="form-control"
|
||||
bind:value={propiedad.ubicacion}
|
||||
placeholder="Ubicación"
|
||||
required
|
||||
/>
|
||||
<label for="ubicacion">Ubicación</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="canthabitaciones"
|
||||
class="form-control"
|
||||
bind:value={propiedad.canthabitaciones}
|
||||
min="1"
|
||||
placeholder="Cantidad de Habitaciones"
|
||||
required
|
||||
/>
|
||||
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="piso"
|
||||
class="form-control"
|
||||
bind:value={propiedad.piso}
|
||||
min="0"
|
||||
placeholder="Piso"
|
||||
/>
|
||||
<label for="piso">Piso</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
id="letra"
|
||||
class="form-control"
|
||||
bind:value={propiedad.letra}
|
||||
maxlength="1"
|
||||
placeholder="Letra"
|
||||
/>
|
||||
<label for="letra">Letra</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<select
|
||||
id="idtipropiedad"
|
||||
class="form-select"
|
||||
bind:value={propiedad.idtipropiedad}
|
||||
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="idtipropiedad">Tipo de Propiedad</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Enviar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{#if mostrarModal == true}
|
||||
<ModalEstatico payload={datosModal} />
|
||||
{/if}
|
||||
14
Front/src/paginas/grupos/AdminG.svelte
Normal file
14
Front/src/paginas/grupos/AdminG.svelte
Normal file
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import ListaAcciones from "../../Componentes/ListaAcciones.svelte";
|
||||
import NavBarAutocompletable from "../../Componentes/NavBarAutocompletable.svelte";
|
||||
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<div class="container mt-5">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Menu del Administrador</h1>
|
||||
<p>Gestiona las cuentas de usuarios, propiedades y permisos desde aquí.</p>
|
||||
</div>
|
||||
<ListaAcciones/>
|
||||
</div>
|
||||
13
Front/src/paginas/grupos/InformesG.svelte
Normal file
13
Front/src/paginas/grupos/InformesG.svelte
Normal file
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import ListaAcciones from "../../Componentes/ListaAcciones.svelte";
|
||||
import NavBarAutocompletable from "../../Componentes/NavBarAutocompletable.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<div class="container mt-5">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Menu Informes</h1>
|
||||
<p>Visualice estadisticas e informes aqui.</p>
|
||||
</div>
|
||||
<ListaAcciones/>
|
||||
</div>
|
||||
14
Front/src/paginas/grupos/InquilinoG.svelte
Normal file
14
Front/src/paginas/grupos/InquilinoG.svelte
Normal file
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import ListaAcciones from "../../Componentes/ListaAcciones.svelte";
|
||||
import NavBarAutocompletable from "../../Componentes/NavBarAutocompletable.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Menu del Inquilino</h1>
|
||||
<p>Gestiona tus Pagos y Busca Propiedades desde aquí.</p>
|
||||
</div>
|
||||
<ListaAcciones/>
|
||||
</div>
|
||||
13
Front/src/paginas/grupos/PropietarioG.svelte
Normal file
13
Front/src/paginas/grupos/PropietarioG.svelte
Normal file
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import ListaAcciones from "../../Componentes/ListaAcciones.svelte";
|
||||
import NavBarAutocompletable from "../../Componentes/NavBarAutocompletable.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<div class="container mt-5">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Menu del Propietario</h1>
|
||||
<p>Gestiona tus propiedades y servicios desde aquí.</p>
|
||||
</div>
|
||||
<ListaAcciones/>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import NavBarLogin from "../lib/NavBarLogin.svelte";
|
||||
import BarraTexto from "../lib/BarraHorizontalConTexto.svelte";
|
||||
import NavBarLogin from "../Componentes/NavBarLogin.svelte";
|
||||
import BarraTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarLogin/><br>
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import FormPostInq from "../lib/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../lib/NavBarAutocompletable.svelte";
|
||||
import TextBar from "../lib/BarraHorizontalConTexto.svelte";
|
||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<div class="col-sm">
|
||||
<br><br>
|
||||
<TextBar text="Formulario Alta Inquilino" />
|
||||
Este es un formulario para crear una cuenta de Propietario.
|
||||
10
Front/src/paginas/login.svelte
Normal file
10
Front/src/paginas/login.svelte
Normal file
@@ -0,0 +1,10 @@
|
||||
<script lang="ts">
|
||||
import Login from "../Componentes/login.svelte"
|
||||
import Navbar from "../Componentes/NavBarLogin.svelte";
|
||||
</script>
|
||||
|
||||
<Navbar/>
|
||||
<div class="position-relative">
|
||||
<br>
|
||||
<Login/>
|
||||
</div>
|
||||
15
Front/src/paginas/menu.svelte
Normal file
15
Front/src/paginas/menu.svelte
Normal file
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import NavBarAuto from "../Componentes/NavBarAutocompletable.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAuto/>
|
||||
<div class="container d-flex justify-content-center align-items-center h-50 text-center">
|
||||
<div>
|
||||
<br><br>
|
||||
<BarraHorizontalConTexto text={"¡Bienvenido a AlquilaFacil!"} />
|
||||
|
||||
<p class="lead mt-3">Por favor, elige una de las opciones disponibles en la barra de navegación superior.</p>
|
||||
<BarraHorizontalConTexto text={""}/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import FormPostInq from "../lib/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../lib/NavBarAutocompletable.svelte";
|
||||
import TextBar from "../lib/BarraHorizontalConTexto.svelte";
|
||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<div class="col-sm">
|
||||
<br><br>
|
||||
<TextBar text="Formulario Alta Propietario" />
|
||||
Este es un formulario para crear una cuenta de Inquilino.
|
||||
3
Front/src/stores/urlStore.js
Normal file
3
Front/src/stores/urlStore.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
export const urlG = readable('http://localhost:5007');
|
||||
28
Front/src/types.d.ts
vendored
Normal file
28
Front/src/types.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
export type PropiedadDto = {
|
||||
id: number,
|
||||
ubicacion: string,
|
||||
tipo: string,
|
||||
piso: string | null,
|
||||
letra: string | null,
|
||||
canthabitaciones: number,
|
||||
servicios: string
|
||||
}
|
||||
export type Permiso = {
|
||||
id: number;
|
||||
descripcion: string;
|
||||
};
|
||||
|
||||
export type Grupo = {
|
||||
id: number;
|
||||
nombre: string;
|
||||
idpermisos: Permiso[];
|
||||
};
|
||||
|
||||
export type Propiedad = {
|
||||
ubicacion: string,
|
||||
canthabitaciones: number,
|
||||
piso: number,
|
||||
letra: string,
|
||||
email: string,
|
||||
idtipropiedad: number,
|
||||
};
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Entidades;
|
||||
|
||||
namespace Modelo;
|
||||
|
||||
@@ -18,7 +16,7 @@ public abstract class RepositorioBase<S>
|
||||
context.SaveChanges();
|
||||
context.Dispose();
|
||||
ret = true;
|
||||
} catch (DbUpdateException ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ public class RepositorioGrupos: RepositorioBase<RepositorioGrupos> {
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public object? Listar()
|
||||
{
|
||||
return Context.Grupos.Include(x => x.Idpermisos);
|
||||
public IQueryable<Permiso> ListarPermisosDeGrupo(string grupo) {
|
||||
var con = Context;
|
||||
return con.Grupos.Where(x=>x.Nombre == grupo).SelectMany(x => x.Idpermisos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo;
|
||||
public class RepositorioPermisos: RepositorioBase<RepositorioPermisos> {
|
||||
public IQueryable<Permiso>? ListarPermisos(string email) {
|
||||
public object? ListarPermisos(string email) {
|
||||
var con = Context;
|
||||
Cliente? cli = con.Clientes.Include(x => x.Idgrupos).FirstOrDefault(c => c.Email == email);
|
||||
if (cli == null) return null;
|
||||
@@ -12,8 +12,8 @@ public class RepositorioPermisos: RepositorioBase<RepositorioPermisos> {
|
||||
var list = con.Clientes
|
||||
.Where(c => c.Dni == cli.Dni)
|
||||
.SelectMany(c => c.Idgrupos)
|
||||
.SelectMany(g => g.Idpermisos)
|
||||
.Distinct();
|
||||
.Include(x=> x.Idpermisos);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Data;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Modelo;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades>
|
||||
{
|
||||
public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
||||
|
||||
public IQueryable<PropiedadesDto> ListarPropiedades(){
|
||||
FormattableString sqlq = $"""
|
||||
@@ -35,27 +36,87 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades>
|
||||
return prop;
|
||||
}
|
||||
|
||||
public bool AñadirPropiedad(Propiedade? prop){
|
||||
if (prop == null) return false;
|
||||
|
||||
var con = Context;
|
||||
|
||||
int count = con.Propiedades.Count()+1;
|
||||
public bool AñadirPropiedad(Propiedade? prop) {
|
||||
if (prop == null) return false;
|
||||
|
||||
prop.Id = count;
|
||||
prop.Idestado = 1;
|
||||
con.Propiedades.Add(prop);
|
||||
var con = Context;
|
||||
|
||||
if (string.IsNullOrEmpty(prop.Letra)) prop.Letra = "_";
|
||||
|
||||
var filasInsertadasParam = new MySqlParameter("@p_filas_insertadas", SqlDbType.Int)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
|
||||
// Ejecutar el procedimiento almacenado
|
||||
var row = con.Database.ExecuteSqlRaw(
|
||||
$"""
|
||||
CALL InsertarPropiedad(@p_ubicacion, @p_cant_habitaciones, @p_piso, @p_letra,
|
||||
@p_dni_propietario, @p_id_tipo_propiedad, @p_filas_insertadas)
|
||||
""",
|
||||
new MySqlParameter("@p_ubicacion", prop.Ubicacion),
|
||||
new MySqlParameter("@p_cant_habitaciones", prop.Canthabitaciones),
|
||||
new MySqlParameter("@p_piso", prop.Piso),
|
||||
new MySqlParameter("@p_letra", prop.Letra),
|
||||
new MySqlParameter("@p_dni_propietario", prop.Dnipropietario),
|
||||
new MySqlParameter("@p_id_tipo_propiedad", prop.Idtipropiedad),
|
||||
filasInsertadasParam
|
||||
);
|
||||
|
||||
return (int)filasInsertadasParam.Value == 1? true: false;
|
||||
}
|
||||
|
||||
public bool PatchPropiedad(Propiedade prop) {
|
||||
var con = Context;
|
||||
Propiedade? propi = con.Propiedades.Include(x=>x.IdServicios).FirstOrDefault(x=>x.Id == prop.Id);
|
||||
|
||||
if (propi == null) return false;
|
||||
|
||||
propi.Canthabitaciones = prop.Canthabitaciones;
|
||||
propi.Idtipropiedad = prop.Idtipropiedad;
|
||||
propi.Ubicacion = prop.Ubicacion;
|
||||
propi.Piso = prop.Piso;
|
||||
propi.Letra = prop.Letra;
|
||||
|
||||
propi.IdServicios.Clear();
|
||||
foreach(Servicio ser in prop.IdServicios) {
|
||||
var servi = con.Servicios.FirstOrDefault(x=>x.Id == ser.Id);
|
||||
if (servi == null) return false;
|
||||
propi.IdServicios.Add(servi);
|
||||
}
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public IQueryable<PropiedadesDto> ObtenerPropiedadesPorEmail(string email) {
|
||||
FormattableString sqlq = $"""
|
||||
SELECT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as TipoPropiedad From Propiedades p
|
||||
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
|
||||
FROM Propiedades p
|
||||
JOIN Clientes c ON c.dni = p.dnipropietario
|
||||
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
||||
WHERE c.email = {email}
|
||||
LEFT JOIN Servicio_Propiedad ps ON ps.idPropiedad = p.id
|
||||
LEFT JOIN Servicios s ON s.Id = ps.idServicio
|
||||
WHERE c.email = {email} AND p.idestado = 1
|
||||
GROUP BY p.id
|
||||
""";
|
||||
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IQueryable<PropiedadesDto> ObtenerPropiedadesDeBajaPorEmail(string email) {
|
||||
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
|
||||
FROM Propiedades p
|
||||
JOIN Clientes c ON c.dni = p.dnipropietario
|
||||
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
||||
LEFT JOIN Servicio_Propiedad ps ON ps.idPropiedad = p.id
|
||||
LEFT JOIN Servicios s ON s.Id = ps.idServicio
|
||||
WHERE c.email = {email} AND p.idestado = 3
|
||||
GROUP BY p.id
|
||||
""";
|
||||
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -74,10 +135,19 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades>
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool BajaPropiedad(int id) {
|
||||
public bool BajaPropiedad(int id, Cliente? cli) {
|
||||
if (cli == null) return false;
|
||||
|
||||
var con = Context;
|
||||
Propiedade prop = con.Propiedades.Find(id);
|
||||
prop.Idestado = 3;
|
||||
Propiedade? prop = con.Propiedades.FirstOrDefault(x=>x.Id == id);
|
||||
if (prop == null) return false;
|
||||
if (prop.Dnipropietario != cli.Dni) return false;
|
||||
|
||||
if(prop.Idestado == 1){
|
||||
prop.Idestado = 3;
|
||||
}else{
|
||||
prop.Idestado = 1;
|
||||
}
|
||||
|
||||
return Guardar(con);
|
||||
|
||||
@@ -101,4 +171,4 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades>
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,15 +24,8 @@ public class RepositorioPropietario: RepositorioBase<RepositorioPropietario> {
|
||||
}
|
||||
|
||||
public Cliente? ObtenerPropietarioPorEmail(string email){
|
||||
|
||||
FormattableString sqlq = $"""
|
||||
SELECT * FROM Clientes c
|
||||
JOIN cliente_Grupos cg ON cg.idgrupo = 1
|
||||
WHERE c.email = {email}
|
||||
LIMIT 1
|
||||
""";
|
||||
|
||||
Cliente? cli = Context.Database.SqlQuery<Cliente?>(sqlq).First();
|
||||
var con = Context;
|
||||
Cliente? cli = con.Clientes.FirstOrDefault(x=>x.Email == email);
|
||||
if (cli == null|| cli.Dni == 0) return null;
|
||||
if (cli.Dni == 0 || cli == null) return null;
|
||||
return cli;
|
||||
|
||||
@@ -8,4 +8,9 @@ public class RepositorioServicios: RepositorioBase<RepositorioServicios> {
|
||||
.SelectMany(x => x.IdServicios)
|
||||
.Select(x=>x.Id);
|
||||
}
|
||||
|
||||
public List<Servicio> ObtenerServiciosPorDescripcion(List<string> servs){
|
||||
var servicios = Context.Servicios.Where(x=> servs.Contains(x.Descripcion)).ToList();
|
||||
return servicios;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,52 +2,53 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Entidades.Dto;
|
||||
using Entidades;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo;
|
||||
|
||||
public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
||||
public bool AltaInquilino(Cliente cli) {
|
||||
var con = Context;
|
||||
|
||||
Grupo? grupo;
|
||||
//check por si la cuenta ya existe (puede ser propietario)
|
||||
Cliente? cli2 = con.Clientes.Find(cli.Dni);
|
||||
if (cli2 != null) {
|
||||
cli = cli2;
|
||||
grupo = con.Grupos.Find(2);
|
||||
if (grupo == null || grupo.Id == 0) return false;
|
||||
cli2.Idgrupos.Add(grupo);
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
var grupo = con.Grupos.Find(2);
|
||||
grupo = con.Grupos.Find(2);
|
||||
if (grupo == null || grupo.Id == 0) return false;
|
||||
|
||||
con.Clientes.Add(cli);
|
||||
Guardar(con);
|
||||
|
||||
con = Context;
|
||||
cli = con.Clientes.Find(cli.Dni) ?? new();
|
||||
if (cli.Dni == 0) return false;
|
||||
|
||||
cli.Idgrupos.Add(grupo);
|
||||
return Guardar(con);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool AltaPropietario(Cliente cli) {
|
||||
var con = Context;
|
||||
|
||||
Grupo? grupo;
|
||||
//check por si la cuenta ya existe (puede ser propietario)
|
||||
Cliente? cli2 = con.Clientes.Find(cli.Dni);
|
||||
if (cli2 != null) {
|
||||
cli = cli2;
|
||||
grupo = con.Grupos.Find(1);
|
||||
if (grupo == null || grupo.Id == 0) return false;
|
||||
cli2.Idgrupos.Add(grupo);
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
var grupo = con.Grupos.Find(1);
|
||||
grupo = con.Grupos.Find(1);
|
||||
if (grupo == null || grupo.Id == 0) return false;
|
||||
|
||||
con.Clientes.Add(cli);
|
||||
Guardar(con);
|
||||
|
||||
con = Context;
|
||||
cli = con.Clientes.Find(cli.Dni) ?? new();
|
||||
if (cli.Dni == 0) return false;
|
||||
|
||||
cli.Idgrupos.Add(grupo);
|
||||
@@ -102,5 +103,20 @@ public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
||||
Guardar(con);
|
||||
}
|
||||
|
||||
public bool CheckGrupo(string email, string grupo) {
|
||||
var con = Context;
|
||||
var usu = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Email == email);
|
||||
bool ret = false;
|
||||
|
||||
if (usu != null && usu.Idgrupos != null) {
|
||||
Parallel.ForEach(usu.Idgrupos, (idGrupo, state) => {
|
||||
if (idGrupo.Nombre == grupo) {
|
||||
ret = true;
|
||||
state.Break();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user