Compare commits
205 Commits
FuncionesP
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b6bf0ba40 | |||
| 83dffcad72 | |||
| a84367cd60 | |||
| afe39d1c80 | |||
| a30e42d06f | |||
| 76582013c4 | |||
| 7bb6c6abc2 | |||
| c180c8ef80 | |||
| a5f78673d4 | |||
| 5d944b0ee4 | |||
| 98414a5ec7 | |||
| b7b7b80072 | |||
| ff63497b61 | |||
| caa654a078 | |||
| fef97e1d05 | |||
| 5444b1dda3 | |||
| 4e5c209584 | |||
| 4ab98a0a2e | |||
| 2435ae803e | |||
| a7355ea540 | |||
| af3933480d | |||
| eceefba391 | |||
| e7b2115d6f | |||
| 84a99a1590 | |||
| 98dbc8c865 | |||
| f6dc641508 | |||
| e5d17c3a38 | |||
| 616c9503bc | |||
| da7f0cf167 | |||
| e0a636ac85 | |||
| 374540a424 | |||
| e6937c65ca | |||
| 033acc1016 | |||
| 3a477e8dc5 | |||
| 76f5c3a9e9 | |||
| 779ab9b982 | |||
| 6f3d985960 | |||
| b4a1d5c0c5 | |||
| c51382b565 | |||
| faa3f386a9 | |||
| deb4b90c18 | |||
| f0da8143eb | |||
| c3aa0db42d | |||
| e3fa663ffa | |||
| 02add8907e | |||
| 6f6d8a4e8c | |||
| 1a5006e832 | |||
| 61eacc5533 | |||
| c825d737fc | |||
| f7d52041ba | |||
| fddafd5234 | |||
| ca44b3cf84 | |||
| 139b855c2c | |||
| 4f44581503 | |||
| 402c98eb6b | |||
| 11f4d38f8b | |||
| 6194e5b4b9 | |||
| b6d78747c8 | |||
| 5df52d8426 | |||
| 2304e7b54b | |||
| 2dd72bf070 | |||
| 6926221353 | |||
| 0961618e40 | |||
| 99591b8cc2 | |||
| 8e385a4710 | |||
| b2f45baec7 | |||
| 190f9a8e10 | |||
| 25e399a5b3 | |||
| 36b8f03421 | |||
| c5a0eb70b8 | |||
| 1d3784d848 | |||
| fdcb74bb11 | |||
| df751ead57 | |||
| eeb2ff1c65 | |||
| e118a3acd2 | |||
| 524a315dc1 | |||
| 4e5e0a4f6f | |||
| b75f672b0a | |||
| de9ff8f0b3 | |||
| 543bc9e5a6 | |||
| ffb860688d | |||
| b98fde72ca | |||
| 701f699c55 | |||
| c1a27baedd | |||
| 6fb6ade153 | |||
| bb995d1587 | |||
| 483a2b5409 | |||
| eadeeb2b08 | |||
| 2ad084cf19 | |||
| 0036f48d19 | |||
| 790cc31f93 | |||
| 25f77f6f48 | |||
| b3ffa657f5 | |||
| 878583664e | |||
| 24c6e43f2d | |||
| b898c6911c | |||
| befe0f2848 | |||
| 8f494b383a | |||
| 09f41c00cd | |||
| dda1032685 | |||
| 21724a372f | |||
| 6c58c6da78 | |||
| 22d68d4ce9 | |||
| cc36565334 | |||
| 3240a526bf | |||
| ed3e9f6b1c | |||
| 0cde92ce19 | |||
| b4090f74e0 | |||
| d0ea1171f8 | |||
| 5e0e92d72b | |||
| e3889d89e1 | |||
| 5ec16897c7 | |||
| d5f5b7de56 | |||
| cdfa52bb19 | |||
| e7747455ec | |||
| 2a8ba5a9f4 | |||
| af231344b6 | |||
| c0bc97fb64 | |||
| 68745cab5e | |||
| b98cf77807 | |||
| 3b96248208 | |||
| 029f8e5fce | |||
| ac2de71179 | |||
| 333ee5d326 | |||
| ccf909e825 | |||
| 72f277ab6c | |||
| c7880b03b3 | |||
| 17fae0e777 | |||
| 7b1e70999f | |||
| 00d4ec8a0e | |||
| 27f20b92e8 | |||
| d0a24ce0b7 | |||
| 1fd0c12793 | |||
| 928c590d1c | |||
| f750ecc77e | |||
| 2b481e2ae2 | |||
| f8692ccdf0 | |||
| 99dc7b28d5 | |||
| ee7c36f373 | |||
| 0cb1ea5266 | |||
| 6592afb3a7 | |||
| 0679fcef40 | |||
| 04a3deeae5 | |||
| 8d4281b715 | |||
| f9470bb005 | |||
| 9c12cfb261 | |||
| f0ba684c8c | |||
| 7137b1bbff | |||
| 1b78956077 | |||
| 6d04fdb48a | |||
| d5cb65403e | |||
| f5e3c4aacd | |||
| 28415f8ba8 | |||
| 9a088a37b2 | |||
| 2b757e527f | |||
| 59981d76d8 | |||
| 13e2566c24 | |||
| 3634736b95 | |||
| a6b4e8394d | |||
| a000b7bd39 | |||
| 013744d129 | |||
| 7565e21df8 | |||
| 280bcd294a | |||
| a85d39cba8 | |||
| d64c46e440 | |||
| a19d2b2a42 | |||
| 062b97515f | |||
| 69b83c8380 | |||
| db7c66e15b | |||
| c362949bdc | |||
| 2ee926eb8a | |||
| 7349454d8f | |||
| 5f56b32afa | |||
| d49e7ec0a1 | |||
| 9a623a8b59 | |||
| cf07c51eb1 | |||
| 9993e427e0 | |||
| c2d29317d5 | |||
| 07cfec619c | |||
| ed0d83dafe | |||
| 5b3e65db2f | |||
| b176ee64b2 | |||
| bd9ac6db0b | |||
| c1c088813a | |||
| 57bfb42f00 | |||
| 28b0a6b785 | |||
| c776e06183 | |||
| cb4f814320 | |||
| 0a9ac0a787 | |||
| 2fa110bb89 | |||
| 45ebdb24be | |||
| a89852804d | |||
| 8c5d0108a1 | |||
| 872415cdde | |||
| f1c9632855 | |||
| bb860b1a16 | |||
| f9204cd835 | |||
| 6f34d628c4 | |||
| 76bcec58d2 | |||
| 3f08dcfc81 | |||
| 990f866a71 | |||
| dbc255dd4b | |||
| c8daa303e4 | |||
| edaf8c6600 | |||
| 9216efc59f |
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CS8602: Dereference of a possibly null reference.
|
||||
dotnet_diagnostic.CS8602.severity = suggestion
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,3 +7,5 @@
|
||||
/Entidades/obj/
|
||||
/Aspnet/obj/
|
||||
/Modelo/bin/
|
||||
Aspnet/bin/
|
||||
node_modules/
|
||||
@@ -10,6 +10,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="minio" Version="6.0.3" />
|
||||
<PackageReference Include="QuestPDF" Version="2024.12.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
35
Aspnet/Builder/DtoBuilder/CanonDtoBuilder.cs
Normal file
35
Aspnet/Builder/DtoBuilder/CanonDtoBuilder.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
|
||||
public class CanonDtoBuilder : Builder<CanonDto>{
|
||||
public CanonDtoBuilder SetId(long id) {
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CanonDtoBuilder SetMesNum(int mesNum) {
|
||||
data.MesNum = mesNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CanonDtoBuilder SetMes(DateTime d){
|
||||
data.Mes = d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CanonDtoBuilder SetMonto(Decimal monto) {
|
||||
data.Monto = monto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CanonDtoBuilder SetDivisa(string divisa) {
|
||||
data.Divisa = divisa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CanonDtoBuilder SetPago(bool p) {
|
||||
data.Pago = p;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
50
Aspnet/Builder/DtoBuilder/ContratoDtoBuilder.cs
Normal file
50
Aspnet/Builder/DtoBuilder/ContratoDtoBuilder.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class ContratoDtoBuilder: Builder<ContratoDto> {
|
||||
public ContratoDtoBuilder SetId(long id ){
|
||||
data.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetUbicacion(string ub){
|
||||
data.Ubicacion = ub;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetTipo(string tipo){
|
||||
data.TipoPropiedad = tipo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetFechaInicio(DateTime fec) {
|
||||
data.Fechainicio = fec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetInquilino(string inquilino){
|
||||
data.Inquilino = inquilino;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetPropietario(string propietario){
|
||||
data.Propietario = propietario;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoDtoBuilder SetEstado(ulong habilitado, ulong cancelado) {
|
||||
bool Habilitado = habilitado == 0?false:true;
|
||||
bool Cancelado = cancelado == 0?false:true;
|
||||
|
||||
if (Habilitado == true && Cancelado == false){
|
||||
data.Estado = "Alquiler Iniciado";
|
||||
} else if (Cancelado == true && Habilitado == false) {
|
||||
data.Estado = "Nunca Empezo Esta Cancelado";
|
||||
} else if (Habilitado == false && Cancelado ==false){
|
||||
data.Estado = "Esta en Proceso";
|
||||
} else if (Habilitado == true && Cancelado == true){
|
||||
data.Estado = "Terminado";
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
95
Aspnet/Builder/DtoBuilder/ContratoPropiedadDtoBuilder.cs
Normal file
95
Aspnet/Builder/DtoBuilder/ContratoPropiedadDtoBuilder.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class ContratoPropiedadDtoBuilder : Builder<ContratoPropiedadDto>
|
||||
{
|
||||
public ContratoPropiedadDtoBuilder SetId(long id)
|
||||
{
|
||||
data.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetUbicacion(string ub)
|
||||
{
|
||||
data.Ubicacion = ub;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetTipo(string tipo)
|
||||
{
|
||||
data.TipoPropiedad = tipo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetFechaInicio(DateTime fec)
|
||||
{
|
||||
data.Fechainicio = fec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetInquilino(string inquilino)
|
||||
{
|
||||
data.Inquilino = inquilino;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetPropietario(string propietario)
|
||||
{
|
||||
data.Propietario = propietario;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetEstado(ulong habilitado, ulong cancelado)
|
||||
{
|
||||
bool Habilitado = habilitado == 0 ? false : true;
|
||||
bool Cancelado = cancelado == 0 ? false : true;
|
||||
|
||||
if (Habilitado == true && Cancelado == false)
|
||||
{
|
||||
data.Estado = "Alquiler Iniciado";
|
||||
}
|
||||
else if (Cancelado == true && Habilitado == false)
|
||||
{
|
||||
data.Estado = "Nunca Empezo Esta Cancelado";
|
||||
}
|
||||
else if (Habilitado == false && Cancelado == false)
|
||||
{
|
||||
data.Estado = "Esta en Proceso";
|
||||
}
|
||||
else if (Habilitado == true && Cancelado == true)
|
||||
{
|
||||
data.Estado = "Terminado";
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetHabitaciones(int habitaciones)
|
||||
{
|
||||
data.Habitaciones = habitaciones;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetPiso(int piso)
|
||||
{
|
||||
data.Piso = piso;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetLetra(string letra)
|
||||
{
|
||||
data.Letra = letra;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetMesesAumento(int mesesAumento)
|
||||
{
|
||||
data.MesesAumento = mesesAumento;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContratoPropiedadDtoBuilder SetMesesDuracion(int mesesDurationContrato)
|
||||
{
|
||||
data.MesesDuracion = mesesDurationContrato;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
34
Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs
Normal file
34
Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class DefectoDtoBuilder: Builder<DefectoDto> {
|
||||
public DefectoDtoBuilder SetId(long id) {
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetDesc(string Descripcion){
|
||||
data.Descripcion = Descripcion;
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetCosto(Decimal Costo){
|
||||
data.Costo = Costo;
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetEstado(string estado){
|
||||
data.Estado = estado;
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetIdContrato(long id){
|
||||
data.Idcontrato = id;
|
||||
return this;
|
||||
|
||||
}
|
||||
public DefectoDtoBuilder SetPagaInquilino(ulong pag){
|
||||
data.Pagainquilino=pag==1?"Si":"No";
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetDivisa(string divisa){
|
||||
data.Divisa = divisa;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
50
Aspnet/Builder/DtoBuilder/GrupoyPermisoDtoBuilder.cs
Normal file
50
Aspnet/Builder/DtoBuilder/GrupoyPermisoDtoBuilder.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class GrupoDtoBuilder : Builder<GrupoDto>
|
||||
{
|
||||
public GrupoDtoBuilder ConNombre(string nombre)
|
||||
{
|
||||
data.Nombre = nombre;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConHabilitado(bool habilitado)
|
||||
{
|
||||
data.Habilitado = habilitado;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConIdGrupo(int id)
|
||||
{
|
||||
data.idgrupo = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConGruposIncluidos(HashSet<string> grupos)
|
||||
{
|
||||
data.GruposIncluidos = grupos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConPermisos(List<PermisoDto> permisos)
|
||||
{
|
||||
data.Permisos = permisos;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class PermisoDtoBuilder : Builder<PermisoDto>
|
||||
{
|
||||
public PermisoDtoBuilder ConId(int id)
|
||||
{
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermisoDtoBuilder ConDescripcion(string descripcion)
|
||||
{
|
||||
data.Descripcion = descripcion;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
17
Aspnet/Builder/DtoBuilder/InformeAlquilerBuilder.cs
Normal file
17
Aspnet/Builder/DtoBuilder/InformeAlquilerBuilder.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Entidades.Informes;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class InformesAlquilerBuilder: Builder<InformesAlquiler>{
|
||||
public InformesAlquilerBuilder SetId(long id){
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
public InformesAlquilerBuilder SetUbicacion(string Ubicacion){
|
||||
data.Ubicacion = Ubicacion;
|
||||
return this;
|
||||
}
|
||||
public InformesAlquilerBuilder SetDivisa(string Divisa){
|
||||
data.Divisa = Divisa;
|
||||
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;
|
||||
}
|
||||
}
|
||||
25
Aspnet/Builder/DtoBuilder/OpcionVentaDtoBuilder.cs
Normal file
25
Aspnet/Builder/DtoBuilder/OpcionVentaDtoBuilder.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class OpcionVentaDtoBuilder: Builder<OpcionVentaDto>{
|
||||
public OpcionVentaDtoBuilder SetId(long id) {
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
public OpcionVentaDtoBuilder SetMonto(decimal monto) {
|
||||
data.Monto = monto;
|
||||
return this;
|
||||
}
|
||||
public OpcionVentaDtoBuilder SetDivisa(string divisa) {
|
||||
data.Divisa = divisa;
|
||||
return this;
|
||||
}
|
||||
public OpcionVentaDtoBuilder SetEnOrden(bool v) {
|
||||
data.EnOrden = v;
|
||||
return this;
|
||||
}
|
||||
public OpcionVentaDtoBuilder SetFueEjercido(int idestado) {
|
||||
data.FueEjercido = idestado==1?false:true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
41
Aspnet/Builder/DtoBuilder/UsuarioDtoBuilder.cs
Normal file
41
Aspnet/Builder/DtoBuilder/UsuarioDtoBuilder.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class UsuarioDtoBuilder : Builder<UsuarioDto>
|
||||
{
|
||||
public UsuarioDtoBuilder SetDni(long dni)
|
||||
{
|
||||
data.Dni = dni;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetNombre(string nombre)
|
||||
{
|
||||
data.Nombre = nombre;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetApellido(string apellido)
|
||||
{
|
||||
data.Apellido = apellido;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetDomicilio(string domicilio)
|
||||
{
|
||||
data.Domicilio = domicilio;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetCelular(string celular)
|
||||
{
|
||||
data.Celular = celular;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetEmail(string email)
|
||||
{
|
||||
data.Email = email;
|
||||
return this;
|
||||
}
|
||||
public UsuarioDtoBuilder SetEmailRecuperacion(string? email)
|
||||
{
|
||||
data.EmailRecuperacion = email ?? "";
|
||||
return this;
|
||||
}
|
||||
}
|
||||
41
Aspnet/Builder/DtoBuilder/VentasDtoBuilder.cs
Normal file
41
Aspnet/Builder/DtoBuilder/VentasDtoBuilder.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class VentasDtoBuilder: Builder<VentasDto> {
|
||||
public VentasDtoBuilder SetId(long id) {
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetMonto(decimal monto) {
|
||||
data.Monto = monto;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetDivisa(string divisa) {
|
||||
data.Divisa = divisa;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetUbicacion(string ubicacion) {
|
||||
data.Ubicacion = ubicacion;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetNombreVendedor(string nombre) {
|
||||
data.NombreVendedor = nombre;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetIdVendedor(long idVendedor) {
|
||||
data.IdVendedor = idVendedor;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetNombreComprador(string nombre) {
|
||||
data.NombreComprador = nombre;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetIdComprador(long Id) {
|
||||
data.IdComprador = Id;
|
||||
return this;
|
||||
}
|
||||
public VentasDtoBuilder SetEstado(string estado) {
|
||||
data.Estado = estado;
|
||||
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;
|
||||
}
|
||||
}
|
||||
15
Aspnet/Builder/PermisoBuilder.cs
Normal file
15
Aspnet/Builder/PermisoBuilder.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Entidades;
|
||||
public class PermisoBuilder : Builder<Permiso>
|
||||
{
|
||||
public PermisoBuilder SetDescripcion(string desc)
|
||||
{
|
||||
data.Descripcion = desc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermisoBuilder SetID(int id)
|
||||
{
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
55
Aspnet/Builder/PrecontratoBuilder.cs
Normal file
55
Aspnet/Builder/PrecontratoBuilder.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public PrecontratoBuilder SetMesesDuracion(int mesesDuracionContrato){
|
||||
data.MesesDurationContrato = mesesDuracionContrato;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrecontratoBuilder SetOpcionVenta(bool tieneOpcionVenta){
|
||||
data.Tieneopcionventa = tieneOpcionVenta == false?0Lu:1Lu;
|
||||
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; } = "";
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using System.Text.Json;
|
||||
using Entidades;
|
||||
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AccionesController: ControllerBase {
|
||||
|
||||
public class AccionesController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpGet("api/acciones")]
|
||||
public IActionResult ListarAccionesPorUsuario([FromHeader(Name ="Email")] string Email, [FromHeader(Name = "Auth")] string Auth) {
|
||||
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});
|
||||
|
||||
if (Auth == "") return Unauthorized(new { esValido = false });
|
||||
|
||||
bool esValido = RepositorioUsuarios.Singleton.CheckToken(Email, Auth);
|
||||
if (!esValido) return Unauthorized();
|
||||
@@ -24,9 +24,11 @@ public class AccionesController: ControllerBase {
|
||||
return Ok(Permisos);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("api/acciones/grupo")]
|
||||
public IActionResult ListarAccionesPorGrupo([FromHeader(Name = "Auth")] string Auth,
|
||||
[FromBody] AccionesPorGrupoDto req) {
|
||||
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);
|
||||
@@ -37,4 +39,35 @@ public class AccionesController: ControllerBase {
|
||||
var permisos = RepositorioGrupos.Singleton.ListarPermisosDeGrupo(req.Grupo);
|
||||
return Ok(permisos);
|
||||
}
|
||||
}
|
||||
/*
|
||||
[HttpPost("api/acciones/crear")] //creo que es codido duplicado
|
||||
public IActionResult CrearAcciones([FromHeader(Name = "Auth")] string Auth,
|
||||
[FromBody] CrearAccionesDto req)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 1); //wip lo voy a usar para crear el permiso que va
|
||||
if (ret == false) return Unauthorized();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(req.Descripcion))
|
||||
{
|
||||
return BadRequest(new { message = "La descripción no puede estar vacía" });
|
||||
}
|
||||
|
||||
if (req.Descripcion.Length > 25)
|
||||
{
|
||||
return BadRequest(new { message = "La descripción no puede ser mayor a 25 caracteres" });
|
||||
}
|
||||
|
||||
var per = new Permiso
|
||||
{
|
||||
Descripcion = req.Descripcion,
|
||||
};
|
||||
var ret2 = RepositorioPermisos.Singleton.CrearPermiso(per);
|
||||
return ret2 ? Ok(new { message = "se creo correctamente" }) : BadRequest(new { message = "No se pudo crear el permiso" });
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
423
Aspnet/Controllers/AdminController.cs
Normal file
423
Aspnet/Controllers/AdminController.cs
Normal file
@@ -0,0 +1,423 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using Entidades.Admin;
|
||||
using Entidades.Dto;
|
||||
using Entidades;
|
||||
using System.Linq.Expressions;
|
||||
using AlquilaFacil.StrategyBusquedaAdmin;
|
||||
using System.Diagnostics;
|
||||
using AlquilaFacil.Builder;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio;
|
||||
using AlquilaFacil.Config;
|
||||
using System.Text.Json;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AdminController: ControllerBase
|
||||
{
|
||||
|
||||
[HttpGet("api/contratos/controlPagos")]
|
||||
public IActionResult obtenerContratosInpagos([FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var contratos = RepositorioContratos.Singleton.ObtenerContratosInpagos();
|
||||
|
||||
List<ContratoDto> dtos = new();
|
||||
foreach (var i in contratos) {
|
||||
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
||||
|| i.DnipropietarioNavigation == null) continue;
|
||||
|
||||
var cont = new ContratoDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetId(i.Id)
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.Build();
|
||||
dtos.Add(cont);
|
||||
}
|
||||
return Ok(dtos);
|
||||
}
|
||||
|
||||
[HttpGet("api/contratos/controlPagos/propiedad")]
|
||||
public IActionResult obtenerPropiedad([FromHeader(Name = "Auth")] string Auth, int id = 0) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (id <= 0) return BadRequest(new { message = "No hay propiedades con id igual o menor a 0"});
|
||||
var i = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||
if (i == null || i.DniinquilinoNavigation == null ||
|
||||
i.IdpropiedadNavigation == null || i.DnipropietarioNavigation == null)return BadRequest(new { message = "Fallo la query"});
|
||||
|
||||
var cont = new ContratoPropiedadDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetId(i.Id)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.SetHabitaciones(i.IdpropiedadNavigation.Canthabitaciones)
|
||||
.SetPiso(i.IdpropiedadNavigation.Piso??0)
|
||||
.SetLetra(i.IdpropiedadNavigation.Letra??"")
|
||||
.SetMesesAumento(i.MesesHastaAumento)
|
||||
.SetMesesDuracion(i.MesesDurationContrato)
|
||||
.Build();
|
||||
|
||||
return Ok(cont);
|
||||
}
|
||||
|
||||
private readonly IMinioClient mc;
|
||||
public AdminController(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("0.0.0.0:9000")
|
||||
.WithSSL(false)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
[HttpGet("/api/admin/contrato/verDocumento")]
|
||||
public IActionResult verDocumento([FromHeader(Name = "Auth")] string Auth, int idcontrato = 0){
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
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.ObtenerContratoPorId(idcontrato);
|
||||
|
||||
try{
|
||||
var memstream = new MemoryStream();
|
||||
|
||||
var goa = new GetObjectArgs()
|
||||
.WithBucket("alquilafacil")
|
||||
.WithObject(contr.UrlContrato)
|
||||
.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", contr.UrlContrato);
|
||||
|
||||
} catch (Exception e){
|
||||
Console.Error.WriteLine(e);
|
||||
return BadRequest(new { message = "Fallo al intentar obtener el archivo del almacenamiento o este no existe"});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("api/admin/contrato/canons")]
|
||||
public IActionResult ObtenerCanones([FromHeader(Name="Auth")]string Auth, int id = 0){
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var cont = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||
if (cont == null) return BadRequest(new { message = "No existe el contrato"});
|
||||
|
||||
var list = RepositorioCanons.Singleton.ObtenerCanonsPorContrato(id);
|
||||
if (list == null) return BadRequest(new { message = "No hay contrato por esa id"});
|
||||
|
||||
DateTime date = DateTime.Now;
|
||||
bool ret =list.Any(x=>x.Pagado ==0 && date > x.Fecha);
|
||||
if (ret != true) return BadRequest(new { message = "Este contrato no tiene canones vencidos"});
|
||||
|
||||
string divisa ="";
|
||||
if (cont.Iddivisa == 0) divisa = "AR$"; else if (cont.Iddivisa == 1) divisa = "US$";
|
||||
|
||||
List<CanonDto> d = new();
|
||||
|
||||
foreach (var i in list) {
|
||||
if (i.Fecha > date) continue;
|
||||
|
||||
var c = new CanonDtoBuilder()
|
||||
.SetId(i.Id)
|
||||
.SetPago(i.Idrecibo==null?false:true)
|
||||
.SetDivisa(divisa==""?"Ugh esta mal cargado la divisa en el contrato":divisa)
|
||||
.SetMes(i.Fecha)
|
||||
.SetMesNum(int.Parse((i.Fecha.Month - cont.Fechainicio.Month).ToString()) + 1)
|
||||
.SetMonto(i.Monto)
|
||||
.Build();
|
||||
d.Add(c);
|
||||
}
|
||||
|
||||
return Ok(d);
|
||||
}
|
||||
|
||||
[HttpPost("api/admin/contrato/marcarPago")]
|
||||
public IActionResult realizarPago([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (dto.Idcontrato<=0) return BadRequest(new { message = "No puede existir un contrato con id 0 o menor"});
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null)return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id"});
|
||||
|
||||
Canon? c = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||
if (c == null) return BadRequest(new { message = "no hay un canon por esa id"});
|
||||
|
||||
Recibo re = new Recibo{
|
||||
Monto = c.Monto,
|
||||
Fecha = DateTime.Now,
|
||||
};
|
||||
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni, "Admin Marca Recibo Como Pago");
|
||||
return ret ?
|
||||
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||
}
|
||||
|
||||
[HttpPost("api/admin/notificarInquilino")]
|
||||
public IActionResult NotificarInquilino([FromHeader(Name ="Auth")]string Auth, NotificarAdmin data){
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null)return Unauthorized();
|
||||
|
||||
if (data.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||
if (data.Idcontrato <= 0) return BadRequest(new {message = "La id de contrato no puede ser 0 o menor"});
|
||||
if (data.Idcanon <= 0) return BadRequest(new {message = "La id de contrato no puede ser 0 o menor"});
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(data.Idcontrato);
|
||||
if (cont == null || cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id"});
|
||||
|
||||
Canon? can = RepositorioCanons.Singleton.ObtenerCanonPorId(data.Idcanon);
|
||||
if (can == null)return BadRequest(new { message = "No existe un canon por esa id"});
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion Inquilino")
|
||||
.SetMensaje(data.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(cont.DniinquilinoNavigation.Dni)
|
||||
.SetDniremitente(cont.DnipropietarioNavigation.Dni)
|
||||
.SetIdpropiedad(cont.IdpropiedadNavigation.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(n, cli.Dni);
|
||||
return ret?
|
||||
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
|
||||
}
|
||||
|
||||
[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/cliente")]
|
||||
public IActionResult ObtenerCliente([FromHeader(Name ="Auth")]string Auth, long dni = 0){
|
||||
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 haber un dni 0 o menor"});
|
||||
|
||||
Cliente? cambio = RepositorioUsuarios.Singleton.ObtenerClientePorDni(dni);
|
||||
if (cambio == null) BadRequest(new { message = "no hay un cliente por ese dni"});
|
||||
|
||||
UpdateUsuarioAdmin a = new UpdateUsuarioAdmin{
|
||||
Apellido = cambio.Apellido,
|
||||
Celular = cambio.Celular,
|
||||
Domicilio = cambio.Domicilio,
|
||||
Nombre = cambio.Nombre,
|
||||
};
|
||||
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
[HttpPatch("api/admin/cliente")]
|
||||
public IActionResult PatchCliente([FromHeader(Name ="Auth")]string Auth, [FromBody]UpdateUsuarioAdmin dto, [FromQuery]long dni=0){
|
||||
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 haber un dni 0 o menor"});
|
||||
|
||||
var validacion2 = checkdto(dto);
|
||||
if (validacion2 != "") return BadRequest(new { message = validacion2});
|
||||
|
||||
Cliente?cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
bool ret = RepositorioUsuarios.Singleton.PatchUsuario(dto, dni, cli.Dni);
|
||||
|
||||
return ret?
|
||||
Ok(new { message = "Se actualizaron los datos"}):
|
||||
BadRequest(new { message = "Fallo al guardar los datos"});
|
||||
}
|
||||
|
||||
public record GrupoI_D(int Id, string Descripcion);
|
||||
[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<GrupoI_D> list = RepositorioGrupos.Singleton.ObtenerGruposPorDni(Dni).Select(x=> new GrupoI_D(x.Id,x.Nombre));
|
||||
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();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||
|
||||
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, cli.Dni);
|
||||
|
||||
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();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||
|
||||
|
||||
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, cli.Dni);
|
||||
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 ret ?
|
||||
Ok(new { message = "Cliente ha sido modificado" }) :
|
||||
BadRequest(new { message = "No se pudo modificar al cliente" });
|
||||
}
|
||||
|
||||
[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"});
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id, cli.Dni);
|
||||
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});
|
||||
}
|
||||
|
||||
private string checkdto(UpdateUsuarioAdmin d){
|
||||
string ret ="";
|
||||
if (d.Nombre=="") ret+="Campo Nombre vacio\n";
|
||||
if (d.Apellido=="") ret+="Campo Apellido vacio\n";
|
||||
if (d.Celular=="") ret+="Campo Celular vacio\n";
|
||||
if (d.Domicilio=="")ret+="Campo Domicilio vacio\n";
|
||||
return 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});
|
||||
|
||||
}
|
||||
}
|
||||
353
Aspnet/Controllers/CargaContratoAdminController.cs
Normal file
353
Aspnet/Controllers/CargaContratoAdminController.cs
Normal file
@@ -0,0 +1,353 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AlquilaFacil.Config;
|
||||
using Modelo;
|
||||
using Entidades.Dto;
|
||||
using Entidades;
|
||||
using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using System.Text.Json;
|
||||
|
||||
[ApiController]
|
||||
public class CargarContratoAdminController: ControllerBase{
|
||||
|
||||
[HttpGet("api/admin/contrato/data")]
|
||||
public IActionResult GetData([FromHeader(Name ="Auth")]string Auth) {
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay usuario por ese token"});
|
||||
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 20);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var divisas = RepositorioDivisas.Singleton.ObtenerDivisas();
|
||||
|
||||
var propiedades = RepositorioPropiedades.Singleton.ListarPropiedades().ToList()
|
||||
.Select(x=> new {id = x.id,
|
||||
ubicacion = x.Ubicacion});
|
||||
|
||||
var inquilinos = RepositorioInquilinos.Singleton.GetInquilinos().ToList()
|
||||
.Select(x=>new {dni=x.Dni, nombre = x.Nombre});
|
||||
|
||||
var propietarios = RepositorioPropietario.Singleton.GetPropietarios().ToList()
|
||||
.Select(x=>new {dni=x.Dni, nombre = x.Nombre});
|
||||
|
||||
return Ok(new {divisas,
|
||||
propiedades,
|
||||
inquilinos,
|
||||
propietarios});
|
||||
}
|
||||
|
||||
[HttpGet("api/admin/contrato/propieades")]
|
||||
public IActionResult GetPropiedadesPorPropietario([FromHeader(Name ="Auth")]string Auth, long dnipropietario){
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay usuario por ese token"});
|
||||
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 20);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var propiedades = RepositorioPropiedades.Singleton.ObtenerPropiedadEnAlquilerPorDni(dnipropietario);
|
||||
return Ok(propiedades);
|
||||
}
|
||||
|
||||
[HttpPost("api/admin/contrato/carga")]
|
||||
public async Task<IActionResult> CargaContrato([FromHeader(Name="Auth")]string Auth) {
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay usuario por ese token"});
|
||||
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 20);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (!Request.HasFormContentType) {
|
||||
return BadRequest(new { message = "La solicitud debe contener datos de formulario (FormData)." });
|
||||
}
|
||||
|
||||
var formData = await Request.ReadFormAsync();
|
||||
if (formData == null) {
|
||||
return BadRequest(new { message = "No se pudieron leer los datos del formulario." });
|
||||
}
|
||||
|
||||
var archivoContrato = Request.Form.Files.FirstOrDefault(x=>x.Name =="archivoContrato");
|
||||
if (archivoContrato == null) return BadRequest(new { message = "Falto Subir el archivo" });
|
||||
|
||||
if (archivoContrato.ContentType != "application/pdf") {
|
||||
return BadRequest(new { message = "El archivo debe ser un PDF." });
|
||||
}
|
||||
|
||||
Contrato? cont; IActionResult? req;
|
||||
|
||||
(cont, req) = ParseContratoFromForm(formData);
|
||||
if (req != null && cont == null) return req;
|
||||
|
||||
var ret = RepositorioContratos.Singleton.AdminCargaContrato(cont, cli.Dni);
|
||||
if(ret == false) return BadRequest( new {message = "No se pudo cargar el contrato" });
|
||||
|
||||
var inq = RepositorioUsuarios.Singleton.ObtenerClientePorDni(cont.Dniinquilino??0);
|
||||
|
||||
cont = RepositorioContratos.Singleton.ObtenerContrato(inq.Email, cont.Idpropiedad ?? 0);
|
||||
if (cont == null) return BadRequest(new { message = "No se pudo recuperar el contrato" });
|
||||
|
||||
|
||||
string nuevoNombreArchivo = $"id:{cont.Id}-inq:{cont.Dniinquilino}-propi:{cont.Dnipropietario}-idprop:{cont.Idpropiedad}.pdf";
|
||||
|
||||
ret = await subirContrato(archivoContrato, nuevoNombreArchivo);
|
||||
if (ret == false) return BadRequest(new { message = "No se pudo subir el archivo" });
|
||||
|
||||
ret = RepositorioContratos.Singleton.AddUrl(cont.Id, nuevoNombreArchivo);
|
||||
if (ret == false) return BadRequest(new { message = "No se pudo guardar la url del contrato" });
|
||||
|
||||
ret = RepositorioContratos.Singleton.GenerarCanones(cont.Id, cli.Dni);
|
||||
if (ret == false) return BadRequest( new { message = "Fallo al generar canones" });
|
||||
|
||||
var noti = new NotificacioneBuilder()
|
||||
.SetDniremitente(int.Parse(cli.Dni.ToString()))
|
||||
.SetIdpropiedad(cont.Idpropiedad ?? 0)
|
||||
.SetDnicliente(cont.Dniinquilino ?? 0)
|
||||
.SetAccion("Notificacion")
|
||||
.SetMensaje($"Contrato Cargado desde Administracion")
|
||||
.SetFecha(DateTime.Now)
|
||||
.SetLeido(false)
|
||||
.Build();
|
||||
|
||||
var noti2 = new NotificacioneBuilder()
|
||||
.SetDniremitente(int.Parse(cli.Dni.ToString()))
|
||||
.SetIdpropiedad(cont.Idpropiedad ?? 0)
|
||||
.SetDnicliente(cont.Dnipropietario ?? 0)
|
||||
.SetAccion("Notificacion")
|
||||
.SetMensaje($"Contrato Cargado desde Administracion")
|
||||
.SetFecha(DateTime.Now)
|
||||
.SetLeido(false)
|
||||
.Build();
|
||||
|
||||
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||
if (ret == false) return BadRequest( new { message = "No se pudo entregar la notificacion al inquilino" });
|
||||
|
||||
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti2);
|
||||
if (ret == false) return BadRequest( new { message = "No se pudo entregar la notificacion al propietario" });
|
||||
|
||||
return Ok(new { message = "Se cargo el contrato" });
|
||||
|
||||
|
||||
}
|
||||
|
||||
private (Contrato? contratoDto, IActionResult? errorResult) ParseContratoFromForm(IFormCollection formData) {
|
||||
if (formData == null) {
|
||||
return (null, BadRequest(new { message = "No se pudieron leer los datos del formulario." }));
|
||||
}
|
||||
|
||||
bool TryParseInt(string? value, out int result) => int.TryParse(value, out result);
|
||||
bool TryParseLong(string? value, out long result) => long.TryParse(value, out result);
|
||||
bool TryParseDecimal(string? value, out decimal result) => decimal.TryParse(value, out result);
|
||||
bool TryParseBool(string? value, out bool result) => bool.TryParse(value, out result);
|
||||
|
||||
int cantGarantMin = 0;
|
||||
if (formData.TryGetValue("cantgarantemin", out var cantGarantMinValues) &&
|
||||
!string.IsNullOrEmpty(cantGarantMinValues.FirstOrDefault()) &&
|
||||
!TryParseInt(cantGarantMinValues.FirstOrDefault(), out cantGarantMin)) {
|
||||
return (null, BadRequest(new { message = "Campo 'cantgarantemin' inválido." }));
|
||||
}
|
||||
if (cantGarantMin<1) return (null, BadRequest(new { message = "Minimo 1 garante" }));
|
||||
|
||||
if (!formData.TryGetValue("dniinquilino", out var dniInqValues) ||
|
||||
string.IsNullOrEmpty(dniInqValues.FirstOrDefault()) ||
|
||||
!TryParseLong(dniInqValues.FirstOrDefault(), out long dniInquilino)) {
|
||||
return (null, BadRequest(new { message = "Campo 'dniinquilino' inválido o faltante." }));
|
||||
}
|
||||
if (dniInquilino<=0) return (null, BadRequest(new { message = "No pueden haber dni 0 o menor" }));
|
||||
|
||||
if (!formData.TryGetValue("dnipropietario", out var dniPropValues) ||
|
||||
string.IsNullOrEmpty(dniPropValues.FirstOrDefault()) ||
|
||||
!TryParseLong(dniPropValues.FirstOrDefault(), out long dniPropietario)) {
|
||||
return (null, BadRequest(new { message = "Campo 'dnipropietario' inválido o faltante." }));
|
||||
}
|
||||
if (dniPropietario<=0) return (null, BadRequest(new { message = "No pueden haber dni 0 o menor" }));
|
||||
|
||||
if (!formData.TryGetValue("iddivisa", out var idDivisaValues) ||
|
||||
string.IsNullOrEmpty(idDivisaValues.FirstOrDefault()) ||
|
||||
!TryParseInt(idDivisaValues.FirstOrDefault(), out int idDivisa)) {
|
||||
return (null, BadRequest(new { message = "Campo 'iddivisa' inválido o faltante." }));
|
||||
}
|
||||
|
||||
if (!formData.TryGetValue("idpropiedad", out var idPropValues) ||
|
||||
string.IsNullOrEmpty(idPropValues.FirstOrDefault()) ||
|
||||
!TryParseInt(idPropValues.FirstOrDefault(), out int idPropiedad)) {
|
||||
return (null, BadRequest(new { message = "Campo 'idpropiedad' inválido o faltante." }));
|
||||
}
|
||||
|
||||
if (!formData.TryGetValue("mesesDurationContrato", out var mesesDurValues) ||
|
||||
string.IsNullOrEmpty(mesesDurValues.FirstOrDefault()) ||
|
||||
!TryParseInt(mesesDurValues.FirstOrDefault(), out int mesesDuration)) {
|
||||
return (null, BadRequest(new { message = "Campo 'mesesDurationContrato' inválido o faltante." }));
|
||||
}
|
||||
|
||||
if (mesesDuration <= 0){
|
||||
return (null, BadRequest(new { message = "No se cargaron los meses de duracion del contrato" }));
|
||||
}
|
||||
|
||||
int mesesHastaAumento = 0;
|
||||
if (formData.TryGetValue("mesesHastaAumento", out var mesesHastaValues) &&
|
||||
!string.IsNullOrEmpty(mesesHastaValues.FirstOrDefault())) {
|
||||
if (!TryParseInt(mesesHastaValues.FirstOrDefault(), out mesesHastaAumento))
|
||||
{
|
||||
return (null, BadRequest(new { message = "Campo 'mesesHastaAumento' inválido." }));
|
||||
}
|
||||
}
|
||||
|
||||
if (mesesHastaAumento <= 0){
|
||||
return (null, BadRequest(new { message = "No se cargaron los meses hasta el aumento" }));
|
||||
}
|
||||
if (mesesDuration<mesesHastaAumento) return (null, BadRequest( new { message = "El contrato no puede durar menos que el tiempo hasta el aumento" } ));
|
||||
|
||||
if (!formData.TryGetValue("monto", out var montoValues) ||
|
||||
string.IsNullOrEmpty(montoValues.FirstOrDefault()) ||
|
||||
!TryParseDecimal(montoValues.FirstOrDefault(), out decimal monto)) {
|
||||
return (null, BadRequest(new { message = "Campo 'monto' inválido o faltante." }));
|
||||
}
|
||||
|
||||
if (monto <= 0.0m){
|
||||
return (null, BadRequest(new { message = "No se cargo el monto de alquiler" }));
|
||||
}
|
||||
|
||||
bool tieneOpcionVenta = false;
|
||||
if (formData.TryGetValue("tieneopcionventa", out var tieneOpcionValues) &&
|
||||
!string.IsNullOrEmpty(tieneOpcionValues.FirstOrDefault())) {
|
||||
if (!TryParseBool(tieneOpcionValues.FirstOrDefault(), out tieneOpcionVenta)) {
|
||||
return (null, BadRequest(new { message = "Campo 'tieneopcionventa' inválido." }));
|
||||
}
|
||||
}
|
||||
|
||||
int divisaOpcionVenta = 0;
|
||||
decimal montoOpcionVenta = 0m;
|
||||
|
||||
if (tieneOpcionVenta) {
|
||||
if (formData.TryGetValue("divisaOpcionVenta", out var divisaOpcValues) &&
|
||||
!string.IsNullOrEmpty(divisaOpcValues.FirstOrDefault())) {
|
||||
if (!TryParseInt(divisaOpcValues.FirstOrDefault(), out int divisaOpcParsed)) {
|
||||
return (null, BadRequest(new { message = "Campo 'divisaOpcionVenta' inválido." }));
|
||||
}
|
||||
divisaOpcionVenta = divisaOpcParsed;
|
||||
}
|
||||
|
||||
if (formData.TryGetValue("montoOpcionVenta", out var montoOpcValues) &&
|
||||
!string.IsNullOrEmpty(montoOpcValues.FirstOrDefault())) {
|
||||
if (!TryParseDecimal(montoOpcValues.FirstOrDefault(), out decimal montoOpcParsed)) {
|
||||
return (null, BadRequest(new { message = "Campo 'montoOpcionVenta' inválido." }));
|
||||
}
|
||||
montoOpcionVenta = montoOpcParsed;
|
||||
}
|
||||
}
|
||||
|
||||
if (montoOpcionVenta <= 0.0m && tieneOpcionVenta){
|
||||
return (null, BadRequest(new { message = "No se cargo el monto de la opcion de venta" }));
|
||||
}
|
||||
|
||||
var cont = new Contrato{
|
||||
Cancelado=0,
|
||||
Habilitado=0,
|
||||
Cantgarantemin=cantGarantMin,
|
||||
Dniinquilino=dniInquilino,
|
||||
Dnipropietario=dniPropietario,
|
||||
Fechainicio=DateTime.Now,
|
||||
Iddivisa=idDivisa,
|
||||
Idpropiedad=idPropiedad,
|
||||
Monto=monto,
|
||||
MesesDurationContrato = mesesDuration,
|
||||
MesesHastaAumento=mesesHastaAumento,
|
||||
|
||||
Idgarantes = ParseGarantes(formData),
|
||||
|
||||
Tieneopcionventa=tieneOpcionVenta?1ul:0ul,
|
||||
|
||||
|
||||
};
|
||||
|
||||
if(cont.Tieneopcionventa==1ul){
|
||||
cont.IdventaNavigation = new Venta{
|
||||
Idestado = 1,
|
||||
Monto= montoOpcionVenta,
|
||||
Iddivisa = divisaOpcionVenta
|
||||
};
|
||||
}
|
||||
|
||||
return (cont, null);
|
||||
}
|
||||
|
||||
private Garante[] ParseGarantes(IFormCollection formData) {
|
||||
var garantes = new List<Garante>();
|
||||
|
||||
var garanteKeys = formData.Keys.Where(k => k.StartsWith("garantes[")).ToList();
|
||||
var garanteCount = garanteKeys.Count / 6;
|
||||
|
||||
for (int i = 0; i < garanteCount; i++) {
|
||||
|
||||
int dni = 0;
|
||||
if (formData.TryGetValue($"garantes[{i}].dni", out var dniValue) &&
|
||||
!string.IsNullOrEmpty(dniValue.FirstOrDefault()))
|
||||
{
|
||||
int.TryParse(dniValue.FirstOrDefault(), out dni);
|
||||
}
|
||||
|
||||
var nombre = formData.TryGetValue($"garantes[{i}].nombre", out var nombreValue) ? nombreValue.ToString() ?? "" : "";
|
||||
var apellido = formData.TryGetValue($"garantes[{i}].apellido", out var apellidoValue) ? apellidoValue.ToString() ?? "" : "";
|
||||
var domicilio = formData.TryGetValue($"garantes[{i}].domicilio", out var domicilioValue) ? domicilioValue.ToString() ?? "" : "";
|
||||
var celular = formData.TryGetValue($"garantes[{i}].celular", out var celularValue) ? celularValue.ToString() ?? "" : "";
|
||||
var domicilioLaboral = formData.TryGetValue($"garantes[{i}].domicilioLaboral", out var domLaboralValue) ? domLaboralValue.ToString() ?? "" : "";
|
||||
|
||||
var garante = new Garante{
|
||||
Dni = dni,
|
||||
Nombre = nombre,
|
||||
Apellido = apellido,
|
||||
Domicilio = domicilio,
|
||||
Celular = celular,
|
||||
Domiciliolaboral = domicilioLaboral
|
||||
};
|
||||
garantes.Add(garante);
|
||||
}
|
||||
|
||||
return garantes.ToArray();
|
||||
}
|
||||
|
||||
|
||||
private readonly IMinioClient mc;
|
||||
public CargarContratoAdminController(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("0.0.0.0:9000")
|
||||
.WithSSL(false)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
943
Aspnet/Controllers/ContratoController.cs
Normal file
943
Aspnet/Controllers/ContratoController.cs
Normal file
@@ -0,0 +1,943 @@
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using AlquilaFacil.Builder;
|
||||
using AlquilaFacil.Config;
|
||||
using AlquilaFacil.Facade;
|
||||
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
|
||||
{
|
||||
|
||||
[HttpPost("api/contrato/GenerarRecibo")]
|
||||
public ActionResult GenerarRecibo([FromHeader(Name = "Auth")] string Auth, MarcarPagoDto dto, bool html = true)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.Idcontrato <= 0) return BadRequest(new { message = "No puede tener un contrato con id 0 o menor" });
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por ese id" });
|
||||
|
||||
if (cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null ||
|
||||
cont.IdpropiedadNavigation.IdtipropiedadNavigation == null) return BadRequest(new { message = "comunicate con el admin esta mal cargado el contratod de alguina forma" });
|
||||
|
||||
Canon? can = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||
if (can == null) return BadRequest(new { message = "no hay un canon para ese contrato con esa fecha" });
|
||||
if (can.IdreciboNavigation == null) return BadRequest(new { message = "No hay un recibo para ese canon" });
|
||||
|
||||
var cdb = new ContratoDtoBuilder()
|
||||
.SetInquilino($"{cont.DniinquilinoNavigation.Nombre} {cont.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(cont.IdpropiedadNavigation.Ubicacion)
|
||||
.SetPropietario($"{cont.DnipropietarioNavigation.Nombre} {cont.DnipropietarioNavigation.Apellido}")
|
||||
.SetId(cont.Id)
|
||||
.SetTipo(cont.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(cont.Fechainicio)
|
||||
.SetEstado(cont.Habilitado, cont.Cancelado)
|
||||
.Build();
|
||||
|
||||
var dof = new DocumentoFacade();
|
||||
MemoryStream? memstr = new();
|
||||
if (html)
|
||||
{
|
||||
dof.GenerarHtml(cdb, can.IdreciboNavigation, memstr);
|
||||
return File(memstr, "text/html", "Recibo.html");
|
||||
}
|
||||
else
|
||||
{
|
||||
dof.GenerarPdf(cdb, can.IdreciboNavigation, memstr);
|
||||
return File(memstr, "application/pdf", "Recibo.pdf");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/marcarPago")]
|
||||
public IActionResult marcarPago([FromHeader(Name = "Auth")] string Auth, MarcarPagoDto dto)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
if (dto.Idcontrato <= 0) return BadRequest(new { message = "No puede existir un contrato con id 0 o menor" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id" });
|
||||
|
||||
if (cli.Dni != cont.Dnipropietario) return BadRequest(new { message = "No sos propietario o intenta volviendote a logear" });
|
||||
|
||||
Canon? c = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||
if (c == null) return BadRequest(new { message = "no hay un canon por esa id" });
|
||||
|
||||
Recibo re = new Recibo
|
||||
{
|
||||
Monto = c.Monto,
|
||||
Fecha = DateTime.Now,
|
||||
};
|
||||
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se guardo correctamente" }) : BadRequest(new { message = "No se pudo guardar" });
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/realizarPago")]
|
||||
public IActionResult realizarPago([FromHeader(Name = "Auth")] string Auth, MarcarPagoDto dto)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
if (dto.Idcontrato <= 0) return BadRequest(new { message = "No puede existir un contrato con id 0 o menor" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id" });
|
||||
|
||||
if (cli.Dni != cont.Dniinquilino) return BadRequest(new { message = "No sos inquilino o intenta volviendote a logear" });
|
||||
|
||||
Canon? c = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||
if (c == null) return BadRequest(new { message = "no hay un canon por esa id" });
|
||||
|
||||
Recibo re = new Recibo
|
||||
{
|
||||
Monto = c.Monto,
|
||||
Fecha = DateTime.Now,
|
||||
};
|
||||
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se guardo correctamente" }) : BadRequest(new { message = "No se pudo guardar" });
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/crearcanons")]
|
||||
public IActionResult crearCanons([FromHeader(Name = "Auth")] string Auth, CrearCanonsDto dto)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
if (dto.idcontrato <= 0) return BadRequest(new { message = "estan mal cargados los datos" });
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "no hay un contrato por esa id" });
|
||||
if (cli.Dni != cont.Dnipropietario) return BadRequest(new { message = "No sos el propietario o intenta volviendote a logear" });
|
||||
|
||||
var ret = RepositorioCanons.Singleton.CrearCanons(dto.aumento, dto.idcontrato, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se crearon los canons correctamente" }) : BadRequest(new { message = "No se pudo guardar" });
|
||||
}
|
||||
|
||||
[HttpGet("api/contratos/canon")]
|
||||
public ActionResult getCanons([FromHeader(Name = "Auth")] string Auth, int id = 0)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var cont = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||
if (cont == null) return BadRequest(new { message = "No existe el contrato" });
|
||||
if (cont.Dnipropietario != cli.Dni && cont.Dniinquilino != cli.Dni) return Unauthorized();
|
||||
|
||||
var list = RepositorioCanons.Singleton.ObtenerCanonsPorContrato(id);
|
||||
if (list == null) return BadRequest(new { message = "No hay contrato por esa id" });
|
||||
|
||||
string divisa = "";
|
||||
if (cont.Iddivisa == 0) divisa = "AR$"; else if (cont.Iddivisa == 1) divisa = "US$";
|
||||
|
||||
List<CanonDto> d = new();
|
||||
|
||||
foreach (var i in list)
|
||||
{
|
||||
int totalMeses = (i.Fecha.Year - cont.Fechainicio.Year) * 12 + (i.Fecha.Month - cont.Fechainicio.Month);
|
||||
int mesNum = totalMeses + 1;
|
||||
var c = new CanonDtoBuilder()
|
||||
.SetId(i.Id)
|
||||
.SetPago(i.Idrecibo == null ? false : true)
|
||||
.SetDivisa(divisa == "" ? "Ugh esta mal cargado la divisa en el contrato" : divisa)
|
||||
.SetMes(i.Fecha)
|
||||
.SetMesNum(mesNum)
|
||||
.SetMonto(i.Monto)
|
||||
.Build();
|
||||
d.Add(c);
|
||||
}
|
||||
|
||||
return Ok(d);
|
||||
}
|
||||
|
||||
[HttpGet("api/contratos/propietario")]
|
||||
public IActionResult ObtenerContratosPorPropietario([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var list = RepositorioContratos.Singleton.ObtenerContratosDePropietario(cli.Dni);
|
||||
|
||||
List<ContratoDto> dtos = new();
|
||||
foreach (var i in list)
|
||||
{
|
||||
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
||||
|| i.DnipropietarioNavigation == null) continue;
|
||||
|
||||
var cont = new ContratoDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetId(i.Id)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.Build();
|
||||
dtos.Add(cont);
|
||||
}
|
||||
return Ok(dtos);
|
||||
}
|
||||
|
||||
[HttpGet("api/contrato/propietario")]
|
||||
public IActionResult ObtenerContratoPorPropietarioPorId([FromHeader(Name = "Auth")] string Auth, int id = 0)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
if (id <= 0) return BadRequest(new { message = "No hay propiedades con id igual o menor a 0" });
|
||||
var i = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||
if (i == null || i.DniinquilinoNavigation == null ||
|
||||
i.IdpropiedadNavigation == null || i.DnipropietarioNavigation == null) return BadRequest(new { message = "Fallo la query" });
|
||||
if (cli.Dni != i.Dnipropietario) return BadRequest(new { message = "No sos el propietario" });
|
||||
|
||||
var cont = new ContratoPropiedadDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetId(i.Id)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.SetHabitaciones(i.IdpropiedadNavigation.Canthabitaciones)
|
||||
.SetPiso(i.IdpropiedadNavigation.Piso ?? 0)
|
||||
.SetLetra(i.IdpropiedadNavigation.Letra ?? "")
|
||||
.SetMesesAumento(i.MesesHastaAumento)
|
||||
.SetMesesDuracion(i.MesesDurationContrato)
|
||||
.Build();
|
||||
|
||||
return Ok(cont);
|
||||
}
|
||||
|
||||
[HttpGet("api/contratos/inquilino")]
|
||||
public IActionResult ObtenerContratosPorInquilino([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var list = RepositorioContratos.Singleton.ObtenerContratosDeInquilino(cli.Dni);
|
||||
|
||||
List<ContratoDto> dtos = new();
|
||||
foreach (var i in list)
|
||||
{
|
||||
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
||||
|| i.DnipropietarioNavigation == null) continue;
|
||||
|
||||
var cont = new ContratoDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetId(i.Id)
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.Build();
|
||||
dtos.Add(cont);
|
||||
}
|
||||
return Ok(dtos);
|
||||
}
|
||||
|
||||
[HttpGet("api/contrato/inquilino")]
|
||||
public IActionResult ObtenerContratoPorInquilinoPorId([FromHeader(Name = "Auth")] string Auth, int id = 0)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
if (id <= 0) return BadRequest(new { message = "No hay propiedades con id igual o menor a 0" });
|
||||
var i = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||
if (i == null || i.DniinquilinoNavigation == null ||
|
||||
i.IdpropiedadNavigation == null || i.DnipropietarioNavigation == null) return BadRequest(new { message = "Fallo la query" });
|
||||
if (cli.Dni != i.Dniinquilino) return BadRequest(new { message = "No sos el inquilino" });
|
||||
|
||||
var cont = new ContratoPropiedadDtoBuilder()
|
||||
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetId(i.Id)
|
||||
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(i.Fechainicio)
|
||||
.SetEstado(i.Habilitado, i.Cancelado)
|
||||
.SetHabitaciones(i.IdpropiedadNavigation.Canthabitaciones)
|
||||
.SetPiso(i.IdpropiedadNavigation.Piso ?? 0)
|
||||
.SetLetra(i.IdpropiedadNavigation.Letra ?? "")
|
||||
.SetMesesAumento(i.MesesHastaAumento)
|
||||
.SetMesesDuracion(i.MesesDurationContrato)
|
||||
.Build();
|
||||
|
||||
return Ok(cont);
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/precontrato")]
|
||||
public IActionResult IniciarPrecontrato([FromHeader(Name = "Auth")] string Auth, [FromBody] PrecontratoDto dto)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) 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))
|
||||
.SetMesesDuracion(dto.MesesDuracionContrato)
|
||||
.SetOpcionVenta(dto.TieneOpcionVenta)
|
||||
.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();
|
||||
|
||||
bool ret;
|
||||
if (dto.TieneOpcionVenta == false)
|
||||
{
|
||||
ret = RepositorioContratos.Singleton.CargaPrecontrato(cli.Dni, precontrato, notificacion);
|
||||
}
|
||||
else
|
||||
{
|
||||
Venta v = new Venta
|
||||
{
|
||||
Idestado = 1,
|
||||
Iddivisa = dto.iddivisa,
|
||||
Monto = dto.MontoOpcion,
|
||||
};
|
||||
ret = RepositorioContratos.Singleton.CargaPrecontratoOpcionVenta(precontrato, notificacion, v, cli.Dni);
|
||||
}
|
||||
|
||||
if (ret == false) return BadRequest(new { message = "No se pudo cargar el precontrato" });
|
||||
|
||||
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 enviar la notificacion" });
|
||||
}
|
||||
|
||||
[HttpGet("api/precontrato/preCargaGarantes/data")]
|
||||
public IActionResult ObtenerDatosParaMostrarleAlInquilinoPreCargaGarantes([FromHeader(Name="Auth")]string Auth, int propiedadId){
|
||||
if (propiedadId<=0) return BadRequest(new { message = "Numero de propiedad inexistente"});
|
||||
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay cliente por ese token" });
|
||||
|
||||
Contrato? contrato = RepositorioContratos.Singleton.ObtenerPreContratoPorIdDePropiedadyCliente(cli, propiedadId);
|
||||
|
||||
if (contrato == null) return BadRequest(new {message = "no se pudo encontrar los datos del precontrato"});
|
||||
|
||||
PreContratoDataDto d = new PreContratoDataDto
|
||||
{
|
||||
TieneOpcionDeVenta = contrato.Tieneopcionventa == 1,
|
||||
|
||||
MontoOpcionDeVenta = contrato.Tieneopcionventa == 1 && contrato.IdventaNavigation != null
|
||||
? contrato.IdventaNavigation.Monto
|
||||
: null,
|
||||
|
||||
MonedaOpcionDeVenta = contrato.Tieneopcionventa == 1
|
||||
&& contrato.IdventaNavigation != null
|
||||
&& contrato.IdventaNavigation.IddivisaNavigation != null
|
||||
? contrato.IdventaNavigation.IddivisaNavigation.Signo
|
||||
: null,
|
||||
|
||||
DuracionEnMeses = contrato.MesesDurationContrato,
|
||||
|
||||
FrecuenciaAumentoEnMeses = contrato.MesesHastaAumento
|
||||
};
|
||||
return Ok(d);
|
||||
}
|
||||
|
||||
[HttpPut("api/contratos/addGarantes")]
|
||||
public IActionResult AddGarantes([FromHeader(Name = "Auth")] string Auth, AltaGarantesDto dto)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
|
||||
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, cli.Dni);
|
||||
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 validacion2 = ValidarCancelarDto(dto);
|
||||
if (validacion2 != "") return BadRequest(new { message = validacion2 });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
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, cli.Dni);
|
||||
if (ret)
|
||||
{
|
||||
prop.Idestado = 1;
|
||||
ret = RepositorioPropiedades.Singleton.PatchPropiedad(prop, pro.Dni);
|
||||
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("");
|
||||
|
||||
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" });
|
||||
if (contr.Dnipropietario != cli.Dni) return BadRequest(new { message = "No Coinside los datos del token con el propietario en el precontrato" });
|
||||
|
||||
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("0.0.0.0: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("");
|
||||
|
||||
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, cli.Dni);
|
||||
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/DocumentoFinal")]
|
||||
public IActionResult ObtenerContratoFinal([FromHeader(Name = "Auth")] string Auth, [FromQuery] long idcontrato)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
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.ObtenerContratoPorId(idcontrato);
|
||||
if (contr == null || contr.Dniinquilino == 0) return BadRequest(new { message = "No hay un contrato 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 && cli.Dni != contr.Dnipropietario) return BadRequest(new { message = "El token no corresponde con el del inquilino" });
|
||||
|
||||
try
|
||||
{
|
||||
var memstream = new MemoryStream();
|
||||
|
||||
var goa = new GetObjectArgs()
|
||||
.WithBucket("alquilafacil")
|
||||
.WithObject(contr.UrlContrato)
|
||||
.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", contr.UrlContrato);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.Error.WriteLine(e);
|
||||
return BadRequest(new { message = "Fallo al intentar obtener el archivo del almacenamiento o este no existe" });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("api/contrato/getdocumento")]
|
||||
public IActionResult ObtenerContrato([FromHeader(Name = "Auth")] string Auth, [FromQuery] long idcontrato)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
|
||||
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();
|
||||
|
||||
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, cli.Dni);
|
||||
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();
|
||||
|
||||
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, cli.Dni);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("api/contratos/garantes")]
|
||||
public IActionResult ObtenerGarantes([FromHeader(Name = "Auth")] string Auth, int idcontrato)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest();
|
||||
if (idcontrato <= 0) return BadRequest(new { message = "No puede ser un contrato id menor a 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No existe el cliente para el token" });
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "El contrato no existe" });
|
||||
|
||||
bool esInquilinoOPropietario = (cont.Dniinquilino ?? 0) == cli.Dni || (cont.Dnipropietario ?? 0) == cli.Dni;
|
||||
bool tienePermiso = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
|
||||
if (esInquilinoOPropietario == false)
|
||||
{
|
||||
return BadRequest(new { message = "No tiene acceso a este path" });
|
||||
}
|
||||
else if (tienePermiso == false && esInquilinoOPropietario == false)
|
||||
{
|
||||
return BadRequest(new { message = "No tiene acceso a este path de admin" });
|
||||
}
|
||||
|
||||
var list = cont.Idgarantes;
|
||||
List<GaranteDto> l = new();
|
||||
foreach (var i in list)
|
||||
{
|
||||
l.Add(new GaranteDtoBuilder()
|
||||
.SetCelular(i.Celular)
|
||||
.SetDni(i.Dni)
|
||||
.SetDomicilio(i.Domicilio)
|
||||
.SetDomicilioLaboral(i.Domiciliolaboral)
|
||||
.SetNombre(i.Nombre)
|
||||
.SetApellido(i.Apellido)
|
||||
.Build());
|
||||
}
|
||||
return Ok(l);
|
||||
}
|
||||
|
||||
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";
|
||||
if (dto.MesesDuracionContrato <= 0) ret += "No puede tener 0 o menos meses de duracion\n";
|
||||
if (dto.MesesDuracionContrato < dto.MesesHastaAumento) ret += "el tiempo hasta aumento no puede ser mayor de \n";
|
||||
if (dto.TieneOpcionVenta == true && dto.MontoOpcion <= 0) ret += "No puede tener un monto de venta negativo o 0";
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
110
Aspnet/Controllers/DefectoController.cs
Normal file
110
Aspnet/Controllers/DefectoController.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using AlquilaFacil.Builder;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class DefectoController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpGet("api/defectos")]
|
||||
public IActionResult ObtenerDefectosEnContrato([FromHeader(Name = "Auth")] string Auth, long Idcontrato = 0)
|
||||
{
|
||||
if (Idcontrato <= 0) return BadRequest(new { message = "La id de contrato no puede ser menor o igual a 0" });
|
||||
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay contrato por esa id" });
|
||||
|
||||
if (cont.Dniinquilino != cli.Dni && cont.Dnipropietario != cli.Dni) return BadRequest(new { message = "no deberias tener acceso a esto" });
|
||||
|
||||
var l = RepositorioDefectos.Singleton.ObtenerDefectosPorIdContrato(Idcontrato);
|
||||
List<DefectoDto> ll = new();
|
||||
foreach (var i in l)
|
||||
{
|
||||
var n = new DefectoDtoBuilder()
|
||||
.SetId(i.Id)
|
||||
.SetDesc(i.Descripcion)
|
||||
.SetCosto(i.Costo)
|
||||
.SetEstado(i.IdestadoNavigation.Descipcion)
|
||||
.SetIdContrato(i.Idcontrato ?? 0)
|
||||
.SetPagaInquilino(i.Pagainquilino)
|
||||
.SetDivisa(i.IddivisaNavigation.Signo)
|
||||
.Build();
|
||||
ll.Add(n);
|
||||
}
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[HttpPost("api/defecto")]
|
||||
public IActionResult AltaDefecto([FromHeader(Name = "Auth")] string Auth, AltaDefectoDto data)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
string r = ValidarDto(data);
|
||||
if (r != "") return BadRequest(new { message = r });
|
||||
|
||||
Defecto defecto = new Defecto
|
||||
{
|
||||
Costo = data.Costo,
|
||||
Descripcion = data.Descripcion,
|
||||
Idcontrato = data.Idcontrato,
|
||||
Iddivisa = data.Iddivisa,
|
||||
Pagainquilino = data.Pagainquilino == 0 ? 0Lu : 1Lu,
|
||||
Idestado = 1,
|
||||
|
||||
};
|
||||
var b = RepositorioDefectos.Singleton.AltaDefecto(defecto, cli.Dni);
|
||||
return b ? Ok(new { message = "Se cargo el Defecto en el sistema" }) : BadRequest(new { message = "No se pudo cargar el defecto en el sistema" });
|
||||
}
|
||||
|
||||
private string ValidarDto(AltaDefectoDto d)
|
||||
{
|
||||
string ret = "";
|
||||
|
||||
if (d == null) return "Dto nulo";
|
||||
if (d.Iddivisa < 0 || d.Iddivisa > 1) ret += "No son divisas validas\n";
|
||||
if (d.Descripcion == "") ret += "La descripcion no puede estar vacia\n";
|
||||
if (d.Idcontrato <= 0) ret += "No puede haber un id de contrato igual o menor a 0\n";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[HttpPut("api/defecto/marcarpago")]
|
||||
public IActionResult MarcarPago([FromHeader(Name = "Auth")] string Auth, long iddefecto = 0)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
if (iddefecto <= 0) return BadRequest(new { message = "No hay canones con id 0 o menor" });
|
||||
bool ret = RepositorioDefectos.Singleton.MarcarPago(iddefecto, cli.Dni);
|
||||
|
||||
return ret ?
|
||||
Ok(new { message = "Se marco como pagado" }) : BadRequest(new { message = "Fallo el acceso a la base de datos o no se encontro el defecto" });
|
||||
}
|
||||
}
|
||||
95
Aspnet/Controllers/EstadisticaController.cs
Normal file
95
Aspnet/Controllers/EstadisticaController.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using AlquilaFacil.Builder;
|
||||
using Entidades.Informes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
[ApiController]
|
||||
public class EstadisticaController : ControllerBase
|
||||
{
|
||||
[HttpGet("/api/stats/Pagos")]
|
||||
public IActionResult EstadisticasPagos([FromHeader(Name ="Auth")] string Auth, int year){
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 6);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
ChartData stats;
|
||||
List<InformePagos> tabla;
|
||||
|
||||
(stats, tabla) = RepositorioEstadisticas.Singleton.InformePagos(year);
|
||||
|
||||
return Ok(new { chart = stats, tabla = tabla});
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("api/stats/alquileresIniciados")]
|
||||
public IActionResult alquileresIniciadosEsteAño([FromHeader(Name = "Auth")] string Auth, int year)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 6);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var validacion2 = RepositorioContratos.Singleton.HayContratosEnAño(year);
|
||||
if (validacion2 == false) return BadRequest(new { message = "No hay contratos en ese año" });
|
||||
var a = RepositorioEstadisticas.Singleton.ObtenerDataIniciadosPorAño(year);
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
[HttpGet("api/contrato/stats")]
|
||||
public IActionResult ObtenerMesesPagos([FromHeader(Name = "Auth")] string Auth, long idcontrato = 0)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (idcontrato <= 0) return BadRequest(new { message = "No puede tener un id contrato menor o igual a 0" });
|
||||
|
||||
var ret = RepositorioEstadisticas.Singleton.ObtenerDatosPagosContrato(idcontrato);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/tabla/alquileresIniciados")]
|
||||
public IActionResult tablaalquileresIniciadosEsteAño([FromHeader(Name = "Auth")] string Auth, int year)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 6);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var validacion2 = RepositorioContratos.Singleton.HayContratosEnAño(year);
|
||||
if (validacion2 == false) return BadRequest(new { message = "No hay contratos en ese año" });
|
||||
var a = RepositorioEstadisticas.Singleton.TablaObtenerContratosIniciadosPorAño(year);
|
||||
if (a == null) return BadRequest(new { message = "Fallo al obtener el contrato" });
|
||||
|
||||
List<InformesAlquiler> informe = new();
|
||||
foreach (var i in a)
|
||||
{
|
||||
var d = new InformesAlquilerBuilder()
|
||||
.SetId(i.Id).SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetDivisa(i.IddivisaNavigation.Signo)
|
||||
.Build();
|
||||
informe.Add(d);
|
||||
}
|
||||
return Ok(informe);
|
||||
}
|
||||
[HttpGet("api/stats/duracionContrato")]
|
||||
public IActionResult DuracionContrato([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 6);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var a = RepositorioEstadisticas.Singleton.ObtenerDataDuracionContratos();
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
[HttpGet("api/tabla/duracionContrato")]
|
||||
public IActionResult TablaDuracionContrato([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 6);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var a = RepositorioEstadisticas.Singleton.TablaObtenerDataDuracionContratos();
|
||||
return Ok(a);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,86 @@
|
||||
#if DEBUG
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using AlquilaFacil.Builder;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class GruposController: ControllerBase {
|
||||
[HttpPost("api/admin/grupos")]
|
||||
public IActionResult CrearGrupo([FromBody] AdminGrupo grupo, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (!string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
var ret2 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||
if (ret2 == false) return BadRequest(ret2);
|
||||
public class GruposController : ControllerBase
|
||||
{
|
||||
[HttpGet("api/admin/grupos")]
|
||||
public IActionResult ObtenerGrupos([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18) ||
|
||||
RepositorioPermisos.Singleton.CheckPermisos(Auth, 9) ||
|
||||
RepositorioPermisos.Singleton.CheckPermisos(Auth, 19);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para ver todos los grupos" });
|
||||
|
||||
if (String.IsNullOrEmpty(grupo.descripcion)) return BadRequest();
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
bool ret = RepositorioGrupos.Singleton.CrearGrupo(grupo.descripcion);
|
||||
return (ret) ? Ok(ret) : BadRequest();
|
||||
var grupos = RepositorioGrupos.Singleton.ListarTodosLosGrupos()
|
||||
.Select(g => new GrupoDtoBuilder()
|
||||
.ConNombre(g.Nombre)
|
||||
.ConIdGrupo(g.Id)
|
||||
.ConHabilitado(g.Habilitado ?? false)
|
||||
.ConGruposIncluidos(new HashSet<string>(g.IdGrupoHijos
|
||||
.Select(id => id.Nombre ?? "")))
|
||||
.ConPermisos(g.Idpermisos.Select(p => new PermisoDtoBuilder()
|
||||
.ConId(p.Id)
|
||||
.ConDescripcion(p.Descripcion)
|
||||
.Build())
|
||||
.ToList())
|
||||
.Build())
|
||||
.ToList();
|
||||
|
||||
return Ok(grupos);
|
||||
|
||||
}
|
||||
[HttpPatch("/api/grupo")]
|
||||
public IActionResult PatchGrupo([FromHeader(Name = "Auth")] string Auth, GrupoDto grupo)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para Gestionar grupos" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
bool ret2 = RepositorioGrupos.Singleton.PatchGrupo(grupo, cli);
|
||||
return ret2 ? Ok(new { message = "Se Modifico el grupo" }) : BadRequest(new { message = "Fallo al editar el grupo" });
|
||||
}
|
||||
|
||||
[HttpPost("/api/grupo")]
|
||||
public IActionResult PostGrupo([FromHeader(Name = "Auth")] string Auth, GrupoDto grupo)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para Gestionar grupos" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
if (grupo.Nombre.Length > 12)
|
||||
{
|
||||
return BadRequest(new { message = "El nombre del grupo no puede superar los 12 caracteres" });
|
||||
}
|
||||
|
||||
bool ret2 = RepositorioGrupos.Singleton.AddGrupo(grupo, cli);
|
||||
return ret2 ? Ok(new { message = "Se Añadio el grupo" }) : BadRequest(new { message = "Fallo al añadirse el grupo" });
|
||||
}
|
||||
|
||||
[HttpDelete("/api/grupo")]
|
||||
public IActionResult DeleteGrupo([FromHeader(Name = "Auth")] string Auth, [FromQuery] int id)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para Gestionar grupos" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
if (id <= 0) return BadRequest(new { message = "El ID del grupo debe ser mayor que cero" });
|
||||
var (ret2, estado) = RepositorioGrupos.Singleton.ToggleGrupo(id, cli);
|
||||
return ret2
|
||||
? Ok(new { message = (estado ? "Grupo habilitado exitosamente" : "Grupo deshabilitado exitosamente") })
|
||||
: BadRequest(new { message = "No se pudo cambiar el estado del grupo" });
|
||||
}
|
||||
}
|
||||
|
||||
public record AdminGrupo(string descripcion);
|
||||
#endif
|
||||
@@ -9,11 +9,12 @@ using System.Security.Cryptography;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class InquilinoController: ControllerBase
|
||||
public class InquilinoController : ControllerBase
|
||||
{
|
||||
|
||||
|
||||
[HttpGet("api/inquilino")]
|
||||
public IActionResult Get([FromHeader(Name = "Auth")] string Auth) {
|
||||
public IActionResult Get([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||
|
||||
@@ -25,30 +26,37 @@ public class InquilinoController: ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("api/inquilino")]
|
||||
public IActionResult Post([FromBody] CrearClienteDto cid, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (string.IsNullOrEmpty(Auth)) return BadRequest(new {message = "El String Auth Esta Vacio"});
|
||||
public IActionResult Post([FromBody] CrearClienteDto cid, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
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(new {message = "Falló el permiso"});
|
||||
if (ret3 == false) return BadRequest(new { message = "Falló el permiso" });
|
||||
|
||||
Cliente? rep = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (rep == null) return Unauthorized();
|
||||
|
||||
var ret = verificarCrearUsuario(cid);
|
||||
if (ret != "") return BadRequest(new {message = ret});
|
||||
|
||||
var cli = new Cliente {
|
||||
if (ret != "") return BadRequest(new { message = ret });
|
||||
|
||||
var cli = new Cliente
|
||||
{
|
||||
Dni = cid.dni,
|
||||
Nombre = cid.nombre,
|
||||
Domicilio = cid.domicilio,
|
||||
Apellido = cid.apellido,
|
||||
Celular = cid.celular,
|
||||
Email = cid.email,
|
||||
Contraseña = Encoding.UTF8.GetBytes(HacerHash(cid.contraseña))
|
||||
Contraseña = Encoding.UTF8.GetBytes(HacerHash(cid.contraseña)),
|
||||
Habilitado = 1,
|
||||
EmailRecuperacion = cid.email,
|
||||
};
|
||||
|
||||
bool ret2 = RepositorioUsuarios.Singleton.AltaInquilino(cli);
|
||||
return (ret2) ? Ok(new {message = "Se dio de alta la cuenta"}) : BadRequest(new {message = "Fallo Dar de Alta El inquilino"});
|
||||
bool ret2 = RepositorioUsuarios.Singleton.AltaInquilino(cli, rep.Dni);
|
||||
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) {
|
||||
private string verificarCrearUsuario(CrearClienteDto cid)
|
||||
{
|
||||
string msg = "";
|
||||
|
||||
if (cid.email == string.Empty) msg += "Falta ingresar el email\n";
|
||||
@@ -62,8 +70,9 @@ public class InquilinoController: ControllerBase
|
||||
|
||||
return msg;
|
||||
}
|
||||
private string HacerHash(string pass){
|
||||
private string HacerHash(string pass)
|
||||
{
|
||||
var buf = SHA256.HashData(Encoding.UTF8.GetBytes(pass));
|
||||
return BitConverter.ToString(buf).Replace("-","");
|
||||
return BitConverter.ToString(buf).Replace("-", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LoginController: ControllerBase
|
||||
if (!usuario) return Unauthorized(new {message = "El usuario no existe o la contraseña es incorrecta"});
|
||||
|
||||
string tokenString = GenerarToken(loginDto);
|
||||
RepositorioUsuarios.Singleton.GuardarToken(loginDto, tokenString);
|
||||
RepositorioUsuarios.Singleton.GuardarToken(loginDto, tokenString, Request.HttpContext.Connection.RemoteIpAddress);
|
||||
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
@@ -52,7 +52,27 @@ public class LoginController: ControllerBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpDelete("/api/logout")]
|
||||
public IActionResult CerrarSesion([FromHeader(Name = "Auth")]string Auth){
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null ) return BadRequest(new { message = "No hay un cliente con ese token" });
|
||||
|
||||
var log = new LoginDto {
|
||||
Email = cli.Email,
|
||||
Contraseña = "",
|
||||
};
|
||||
|
||||
string tokenString = GenerarToken(log);
|
||||
|
||||
try{
|
||||
RepositorioUsuarios.Singleton.GuardarToken(log, tokenString, Request.HttpContext.Connection.RemoteIpAddress, "Cerrar Sesión");
|
||||
} catch {
|
||||
return BadRequest( new { message = "Fallo al cambiar el token" } );
|
||||
}
|
||||
return Ok(new { message = "Se Cerro la sesion" });
|
||||
}
|
||||
|
||||
private string GenerarToken(LoginDto loginDto){
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
var key = Encoding.ASCII.GetBytes("ffb2cdc15d472e41a5b626e294c45020");
|
||||
|
||||
70
Aspnet/Controllers/LogsController.cs
Normal file
70
Aspnet/Controllers/LogsController.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class LogsController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpGet("/api/Logs")]
|
||||
public IActionResult ObtenerLogs([FromHeader(Name = "Auth")] string Auth, int pag = 1)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 7);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
if (pag <= 0) return BadRequest(new { message = "no puede haber una pagina 0 o menor" });
|
||||
|
||||
pag -= 1;
|
||||
|
||||
var l = RepositorioLogs.Singleton.ObtenerLogsPaginado(pag);
|
||||
List<LogDto> ll = new();
|
||||
foreach (var i in l)
|
||||
{
|
||||
ll.Add(new LogDto
|
||||
{
|
||||
Fecha = i.Fecha,
|
||||
Accion = i.Accion,
|
||||
Dniusuario = i.Dniusuario,
|
||||
});
|
||||
}
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[HttpGet("/api/Logs/detalle")]
|
||||
public IActionResult ObtenerLogs([FromHeader(Name = "Auth")] string Auth, [FromQuery] DateTime fecha, [FromQuery] long idusuario)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 7);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
if (idusuario <= 0) return BadRequest(new { message = "no puede haber un id 0 o menor" });
|
||||
|
||||
var l = RepositorioLogs.Singleton.ObtenerDetallesLogs(fecha, idusuario);
|
||||
List<LogDetalleDto> ll = new();
|
||||
foreach (var i in l)
|
||||
{
|
||||
ll.Add(new LogDetalleDto
|
||||
{
|
||||
Fecha = i.Fecha,
|
||||
Dniusuario = i.Dniusuario,
|
||||
NombreTabla = i.NombreTabla,
|
||||
Columna = i.Columna,
|
||||
ValorAnterior = i.ValorAnterior,
|
||||
ValorNuevo = i.ValorNuevo,
|
||||
});
|
||||
}
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[HttpGet("/api/Logs/cantPag")]
|
||||
public IActionResult cantidadPaginas([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 7);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
int c = RepositorioLogs.Singleton.ObtenerCantidadPaginas();
|
||||
return Ok(c);
|
||||
}
|
||||
}
|
||||
166
Aspnet/Controllers/NotificacionesController.cs
Normal file
166
Aspnet/Controllers/NotificacionesController.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
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();
|
||||
foreach (Notificacione i in notificaciones)
|
||||
{
|
||||
if (i.DniclienteNavigation == null || i.DniremitenteNavigation == null) return BadRequest(new { message = "Esta mal cargado el precontrato" });
|
||||
var dto = new NotificacionDtoBuilder()
|
||||
.SetRemitente(i.DniremitenteNavigation.Email ?? "")
|
||||
.SetAccion(i.Accion ?? "")
|
||||
.SetMensaje(i.Mensaje ?? "")
|
||||
.SetFecha(i.Fecha)
|
||||
.SetPropiedad(i.Idpropiedad.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" });
|
||||
}
|
||||
|
||||
[HttpPost("api/notificarInquilino")]
|
||||
public IActionResult NotificarInq([FromHeader(Name = "Auth")] string Auth, [FromBody] AvisoInquilinoDto data)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (data.Mensaje == "") return BadRequest(new { message = "El campo Mensaje esta vacio" });
|
||||
if (data.Idpropiedad <= 0) return BadRequest(new { message = "La id de propiedad no puede ser 0 o menor" });
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(data.Idpropiedad);
|
||||
if (cont == null || cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id" });
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion Inquilino")
|
||||
.SetMensaje(data.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(cont.DniinquilinoNavigation.Dni)
|
||||
.SetDniremitente(cont.DnipropietarioNavigation.Dni)
|
||||
.SetIdpropiedad(cont.IdpropiedadNavigation.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(n);
|
||||
return ret ?
|
||||
Ok(new { message = "se envio el aviso" }) : BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
}
|
||||
|
||||
[HttpPost("api/notificar/ConsultaCompra")]
|
||||
public IActionResult EnviarConsultaCompra([FromHeader(Name = "Auth")] string Auth, AltaNotificacionDto dto)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 16);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
|
||||
return Unauthorized();
|
||||
|
||||
}
|
||||
|
||||
if (dto.Accion == "") return BadRequest(new { message = "El campo Accion esta vacio" });
|
||||
if (dto.Mensaje == "") return BadRequest(new { message = "El campo Mensaje esta vacio" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.Propiedad);
|
||||
if (prop == null) return BadRequest(new { message = "No hay una propiedad con id 0 o menor" });
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Consulta Compra")
|
||||
.SetMensaje(dto.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(prop.Dnipropietario ?? 0)
|
||||
.SetDniremitente(cli.Dni)
|
||||
.SetIdpropiedad(prop.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret2 = RepositorioNotificaciones.Singleton.AltaNotificacion(n, cli.Dni);
|
||||
return ret2 ?
|
||||
Ok(new { message = "se envio el aviso" }) : BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
|
||||
}
|
||||
}
|
||||
61
Aspnet/Controllers/PermisoController.cs
Normal file
61
Aspnet/Controllers/PermisoController.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using AlquilaFacil.Builder;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class PermisoController : ControllerBase
|
||||
{
|
||||
[HttpPost("api/permisos")]
|
||||
public IActionResult CrearPermiso([FromHeader(Name = "Auth")] string Auth, PermisoDto perm)
|
||||
{
|
||||
var ret1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 17);
|
||||
if (ret1 == false) return BadRequest(new { message = "No tienes permiso para esto" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
if (String.IsNullOrWhiteSpace(perm.Descripcion)) return BadRequest(new { message = "No puede tener una descripcion vacia" });
|
||||
if (perm.Descripcion.Length > 25) return BadRequest(new { message = "la descripcion no puede tener más de 25 caractéres" });
|
||||
|
||||
var permiso = new PermisoBuilder().SetDescripcion(perm.Descripcion).Build();
|
||||
|
||||
var ret = RepositorioPermisos.Singleton.CrearPermiso(permiso, cli);
|
||||
|
||||
return ret ? Ok() : BadRequest();
|
||||
}
|
||||
[HttpPatch("api/permisos")]
|
||||
public IActionResult PatchPermiso([FromHeader(Name = "Auth")] string Auth, PermisoDto perm)
|
||||
{
|
||||
var ret1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 17);
|
||||
if (ret1 == false) return BadRequest(new { message = "No tienes permiso para esto" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
if (perm.Id <= 0) return BadRequest(new { message = "No puede haber una id 0 o menor" });
|
||||
if (String.IsNullOrWhiteSpace(perm.Descripcion)) return BadRequest(new { message = "No puede tener una descripcion vacia" });
|
||||
if (perm.Descripcion.Length > 25) return BadRequest(new { message = "la descripcion no puede tener más de 25 caractéres" });
|
||||
|
||||
var permiso = new PermisoBuilder().SetDescripcion(perm.Descripcion).SetID(perm.Id).Build();
|
||||
|
||||
var ret = RepositorioPermisos.Singleton.PatchPermiso(permiso, cli);
|
||||
|
||||
return ret ? Ok() : BadRequest();
|
||||
}
|
||||
[HttpGet("/api/permisos/todos")]
|
||||
public IActionResult ObtenerTodosLosPermisos([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para ver Todos los permisos" });
|
||||
|
||||
var permisos = RepositorioPermisos.Singleton.ListarPermisos();
|
||||
var perms = permisos.Select(permiso => new PermisoDtoBuilder()
|
||||
.ConId(permiso.Id)
|
||||
.ConDescripcion(permiso.Descripcion)
|
||||
.Build());
|
||||
return Ok(perms);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#if DEBUG
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class PermisosController: ControllerBase {
|
||||
[HttpPost("api/admin/permisos")]
|
||||
public IActionResult CrearPermisos([FromBody] AdminPermiso permiso, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (!string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
var ret2 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (ret2 == false) return BadRequest(ret2);
|
||||
|
||||
if (String.IsNullOrEmpty(permiso.descripcion)) return BadRequest();
|
||||
|
||||
bool ret = RepositorioPermisos.Singleton.CrearPermiso(permiso.descripcion);
|
||||
return (ret) ? Ok(ret) : BadRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public record AdminPermiso(string descripcion);
|
||||
#endif
|
||||
@@ -6,64 +6,178 @@ using Modelo;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class PropiedadesController: ControllerBase {
|
||||
public class PropiedadesController : ControllerBase
|
||||
{
|
||||
[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();
|
||||
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();
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||
IQueryable<PropiedadesDto> ret;
|
||||
|
||||
if (pag == 0)
|
||||
{
|
||||
ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = RepositorioPropiedades.Singleton.ListarPropiedadesPorPagina(pag);
|
||||
}
|
||||
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("/api/propiedades/Venta")]
|
||||
public IActionResult ObtenerPropiedadesParaVenta([FromHeader(Name = "Auth")] string Auth, int pag = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 16);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (pag <= 0) return BadRequest(new { message = "no existe una pagina 0" });
|
||||
|
||||
pag -= 1;
|
||||
|
||||
var props = RepositorioPropiedades.Singleton.ObtenerPropiedadesEnVenta(pag);
|
||||
if (props == null) return BadRequest(new { message = "no tengo claro que fallo creo que no existen propiedades en venta" });
|
||||
|
||||
List<PropiedadesVentaDto> l = new();
|
||||
|
||||
foreach (var i in props)
|
||||
{
|
||||
var p = new PropiedadesVentaDto
|
||||
{
|
||||
Id = i.Id,
|
||||
Ubicacion = i.Ubicacion,
|
||||
Canthabitaciones = i.Canthabitaciones,
|
||||
Divisa = i.IddivisaNavigation.Signo,
|
||||
Letra = i.Letra ?? "",
|
||||
Monto = i.Monto,
|
||||
Piso = i.Piso ?? 0,
|
||||
Servicios = string.Join(", ", i.IdServicios.Select(s => s.Descripcion)),
|
||||
Tipo = i.IdtipropiedadNavigation.Descripcion,
|
||||
};
|
||||
l.Add(p);
|
||||
}
|
||||
|
||||
int cantpag = RepositorioPropiedades.Singleton.ObtenerPaginasDePropiedadesEnVenta();
|
||||
|
||||
return Ok(new { propiedades = l, cantpaginas = cantpag });
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedades/Venta/Propietario")]
|
||||
public IActionResult ObtenerPropiedadesVentaDePropietario([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 15);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var props = RepositorioPropiedades.Singleton.ObtenerPropiedadesAVentaPorDni(cli.Dni);
|
||||
List<PropiedadesDto> ll = new();
|
||||
|
||||
foreach (var i in props)
|
||||
{
|
||||
var a = new PropiedadesDto
|
||||
{
|
||||
id = i.Id,
|
||||
Ubicacion = i.Ubicacion,
|
||||
canthabitaciones = i.Canthabitaciones,
|
||||
Iddivisa = i.Iddivisa,
|
||||
letra = i.Letra ?? "",
|
||||
Monto = (int)i.Monto, //mmmm
|
||||
piso = i.Piso ?? 0,
|
||||
Servicios = string.Join(", ", i.IdServicios.Select(x => x.Descripcion)),
|
||||
Tipo = i.IdtipropiedadNavigation.Descripcion,
|
||||
};
|
||||
ll.Add(a);
|
||||
}
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[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();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||
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" });
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(Id);
|
||||
if (ret == null) return BadRequest(new {message ="No existe la propiedad"});
|
||||
if (ret == null) return BadRequest(new { message = "No existe la propiedad" });
|
||||
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")]
|
||||
public IActionResult ObtenerPropiedadesPorPropietario (
|
||||
public IActionResult ObtenerPropiedadesPorPropietario(
|
||||
[FromHeader(Name = "Email")] string email,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
[FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
email = email.Trim();
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new {message ="falta campo email"});
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new { message = "falta campo email" });
|
||||
|
||||
IQueryable<PropiedadesDto> ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedades/Propietario/Bajas")]
|
||||
public IActionResult ObtenerPropiedadesPorPropietarioBajas (
|
||||
public IActionResult ObtenerPropiedadesPorPropietarioBajas(
|
||||
[FromHeader(Name = "Email")] string email,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
[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"});
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new { message = "falta campo email" });
|
||||
|
||||
IQueryable<PropiedadesDto> ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesDeBajaPorEmail(email);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost("api/propiedad")]
|
||||
public IActionResult AltaPropiedad([FromBody] AltaPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth) {
|
||||
public IActionResult AltaPropiedad([FromBody] AltaPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 1);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
@@ -72,39 +186,47 @@ public class PropiedadesController: ControllerBase {
|
||||
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"});
|
||||
if (cli == null) return BadRequest(new { message = "El email no corresponde a un propietario" });
|
||||
|
||||
Propiedade Prop = new Propiedade{
|
||||
Propiedade Prop = new Propiedade
|
||||
{
|
||||
Canthabitaciones = propiedad.Canthabitaciones,
|
||||
Dnipropietario = cli.Dni,
|
||||
Idtipropiedad = propiedad.Idtipropiedad,
|
||||
Ubicacion = propiedad.Ubicacion,
|
||||
Letra = propiedad.Letra ?? null,
|
||||
Piso = propiedad.Piso ?? null,
|
||||
Monto = propiedad.Monto,
|
||||
Iddivisa = propiedad.Iddivisa,
|
||||
};
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop);
|
||||
return (ret)?
|
||||
Ok(new { message = "Fue Cargado Correctamente"}) :
|
||||
BadRequest(new { message = "Fallo al momento de añadir la propiedad a la base de datos"});
|
||||
Cliente? responsable = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop, responsable.Dni);
|
||||
return (ret) ?
|
||||
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) {
|
||||
|
||||
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"});
|
||||
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{
|
||||
|
||||
Propiedade Prop = new Propiedade
|
||||
{
|
||||
Id = propiedad.id,
|
||||
Canthabitaciones = propiedad.Canthabitaciones,
|
||||
Dnipropietario = cli.Dni,
|
||||
@@ -113,106 +235,123 @@ public class PropiedadesController: ControllerBase {
|
||||
Letra = propiedad.Letra ?? null,
|
||||
Piso = propiedad.Piso ?? null,
|
||||
IdServicios = servs,
|
||||
Monto = propiedad.Monto,
|
||||
Iddivisa = propiedad.Iddivisa,
|
||||
};
|
||||
|
||||
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop);
|
||||
return (ret)?
|
||||
Ok(new {message = "Fue modificado Correctamente"}):
|
||||
BadRequest(new {message = "Fallo al modificar la base de datos"});
|
||||
}
|
||||
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop, cli.Dni);
|
||||
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, [FromHeader(Name = "Email")] string email){
|
||||
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 (String.IsNullOrEmpty(email)) return BadRequest(new { message = "Fallo al identificarse el usuario"});
|
||||
if (id <= 0) return BadRequest(new { message = "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" });
|
||||
|
||||
Cliente? propie = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(email);
|
||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id, propie);
|
||||
|
||||
return ret ?
|
||||
Ok(new { message = $"Se Cambio el estado de la propiedad con id {id}"}):
|
||||
BadRequest(new {message="Fallo al cambiar el estado de la propiedad"});
|
||||
}
|
||||
return ret ?
|
||||
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) {
|
||||
public IActionResult AñadirServicio([FromBody] ServicioAPropiedadDto Servicios, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
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"});
|
||||
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(new {message ="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(new {message ="Los Servicios Se Cargaron correctamente a la propiedad"}) : BadRequest(new {message ="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) {
|
||||
public IActionResult EliminarServicio([FromBody] ServicioAPropiedadDto servicio, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
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"});
|
||||
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" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
|
||||
var serv = RepositorioServicios.Singleton.ObtenerServiciosPorPropiedad(servicio.propiedadid);
|
||||
|
||||
var repetidos = serv.Intersect(servicio.idServicios);
|
||||
|
||||
bool ret = RepositorioPropiedades.Singleton.BajaServiciosAPropiedad(servicio.propiedadid, servicio.idServicios);
|
||||
|
||||
bool ret = RepositorioPropiedades.Singleton.BajaServiciosAPropiedad(servicio.propiedadid, servicio.idServicios, cli.Dni);
|
||||
|
||||
return ret ?
|
||||
Ok(new {message ="Se Eliminaron los servicios seleccionados de la propiedad"}) : BadRequest(new {message ="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" });
|
||||
|
||||
}
|
||||
|
||||
private string ValidarPropiedad(AltaPropiedadDto prop) {
|
||||
private string ValidarPropiedad(AltaPropiedadDto prop)
|
||||
{
|
||||
if (prop == null) return "Esta mal formado el body de la request";
|
||||
|
||||
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 (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 (prop.Monto <= 1) ret += "El monto tiene que ser como minimo mayor a 0";
|
||||
|
||||
if (prop.Iddivisa < 0 || prop.Iddivisa > 1) ret += "se tiene que elejir entre AR$ y US$";
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
private string ValidarPropiedad(PatchPropiedadDto prop) {
|
||||
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 (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.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.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 (prop.Monto <= 1) ret += "El monto tiene que ser como minimo mayor a 0";
|
||||
|
||||
if (prop.Iddivisa < 0 || prop.Iddivisa > 1) ret += "se tiene que elejir entre AR$ y US$";
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ using Modelo;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class PropietarioController: ControllerBase {
|
||||
public class PropietarioController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpGet("api/propietario")]
|
||||
public IActionResult ObtenerPropietarioPorDni(long Dni, [FromHeader(Name ="Auth")] string Auth) {
|
||||
public IActionResult ObtenerPropietarioPorDni(long Dni, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
@@ -22,32 +24,40 @@ public class PropietarioController: ControllerBase {
|
||||
}
|
||||
|
||||
[HttpPost("api/propietario")]
|
||||
public IActionResult AltaPropietario([FromBody]CrearClienteDto Propietario,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
public IActionResult AltaPropietario([FromBody] CrearClienteDto Propietario,
|
||||
[FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 5);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
Cliente? rep = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (rep == null) return Unauthorized();
|
||||
|
||||
string validacion2 = verificarCrearUsuario(Propietario);
|
||||
if (validacion2 != "") return BadRequest(validacion2);
|
||||
|
||||
var cli = new Cliente {
|
||||
|
||||
var cli = new Cliente
|
||||
{
|
||||
Dni = Propietario.dni,
|
||||
Nombre = Propietario.nombre,
|
||||
Domicilio = Propietario.domicilio,
|
||||
Apellido = Propietario.apellido,
|
||||
Celular = Propietario.celular,
|
||||
Email = Propietario.email,
|
||||
Contraseña = Encoding.UTF8.GetBytes(HacerHash(Propietario.contraseña))
|
||||
Contraseña = Encoding.UTF8.GetBytes(HacerHash(Propietario.contraseña)),
|
||||
Habilitado = 1,
|
||||
EmailRecuperacion = Propietario.email,
|
||||
};
|
||||
|
||||
bool ret = RepositorioUsuarios.Singleton.AltaPropietario(cli);
|
||||
return ret ?
|
||||
Ok(new {message = "Se añadio el propietario exitosamente"}) : BadRequest();
|
||||
bool ret = RepositorioUsuarios.Singleton.AltaPropietario(cli, rep.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se añadio el propietario exitosamente" }) : BadRequest();
|
||||
}
|
||||
|
||||
[HttpPatch("api/propietarios")]
|
||||
public IActionResult PatchPropietario([FromBody]CrearClienteDto Propietario, [FromHeader(Name = "Auth")] string Auth){
|
||||
public IActionResult PatchPropietario([FromBody] CrearClienteDto Propietario, [FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 5);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
@@ -55,7 +65,8 @@ public class PropietarioController: ControllerBase {
|
||||
string validacion2 = verificarCrearUsuario(Propietario);
|
||||
if (validacion2 != "") return BadRequest(validacion2);
|
||||
|
||||
var cli = new Cliente {
|
||||
var cli = new Cliente
|
||||
{
|
||||
Dni = Propietario.dni,
|
||||
Nombre = Propietario.nombre,
|
||||
Domicilio = Propietario.domicilio,
|
||||
@@ -65,11 +76,12 @@ public class PropietarioController: ControllerBase {
|
||||
Contraseña = Encoding.UTF8.GetBytes(HacerHash(Propietario.contraseña))
|
||||
};
|
||||
var ret = RepositorioUsuarios.Singleton.ActualizarPropietario(cli);
|
||||
return ret ?
|
||||
Ok(new {message = "Se Modifico el propietario exitosamente"}) : BadRequest();
|
||||
return ret ?
|
||||
Ok(new { message = "Se Modifico el propietario exitosamente" }) : BadRequest();
|
||||
}
|
||||
|
||||
private string verificarCrearUsuario(CrearClienteDto cid) {
|
||||
private string verificarCrearUsuario(CrearClienteDto cid)
|
||||
{
|
||||
string msg = "";
|
||||
|
||||
if (cid.email == string.Empty) msg += "Falta ingresar el email\n";
|
||||
@@ -83,8 +95,9 @@ public class PropietarioController: ControllerBase {
|
||||
|
||||
return msg;
|
||||
}
|
||||
private string HacerHash(string pass){
|
||||
private string HacerHash(string pass)
|
||||
{
|
||||
var buf = SHA256.HashData(Encoding.UTF8.GetBytes(pass));
|
||||
return BitConverter.ToString(buf).Replace("-","");
|
||||
return BitConverter.ToString(buf).Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class ServiciosController: ControllerBase {
|
||||
|
||||
}
|
||||
177
Aspnet/Controllers/UsuarioController.cs
Normal file
177
Aspnet/Controllers/UsuarioController.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using AlquilaFacil.Builder;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using Entidades;
|
||||
using AlquilaFacil.Emailer.Sender;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class UsuarioController : ControllerBase
|
||||
{
|
||||
[HttpGet("/api/usuario")]
|
||||
public IActionResult ObtenerInfoUsuario([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un usuari por ese token" });
|
||||
|
||||
var usu = new UsuarioDtoBuilder()
|
||||
.SetNombre(cli.Nombre).SetApellido(cli.Apellido)
|
||||
.SetEmail(cli.Email).SetCelular(cli.Celular)
|
||||
.SetDni(cli.Dni).SetDomicilio(cli.Domicilio)
|
||||
.SetEmailRecuperacion(cli.EmailRecuperacion)
|
||||
.Build();
|
||||
return Ok(usu);
|
||||
}
|
||||
|
||||
public class bodyCambiarContraseña
|
||||
{
|
||||
public string contraseña { get; set; } = "";
|
||||
}
|
||||
|
||||
[HttpPatch("/api/usuario")]
|
||||
public IActionResult CambiarPass([FromHeader(Name = "Auth")] string Auth, [FromBody] bodyCambiarContraseña body)
|
||||
{
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un usuario por ese token" });
|
||||
|
||||
if (body.contraseña.Length < 8) return BadRequest(new { message = "Tiene que tener por lo menos 8 caracteres" });
|
||||
|
||||
bool ret = RepositorioUsuarios.Singleton.CambiarContraseña(body.contraseña, cli);
|
||||
return ret ? Ok(new { message = "Contraseña cambiada con éxito" }) : BadRequest(new { message = "No se pudo cambiar la contraseña" });
|
||||
}
|
||||
|
||||
public class bodyCambiarContraAdmin : bodyCambiarContraseña
|
||||
{
|
||||
public long Dni { get; set; }
|
||||
}
|
||||
|
||||
[HttpPatch("/api/admin/contraseña")]
|
||||
public IActionResult CambiarPassAdmin([FromHeader(Name = "Auth")] string Auth, [FromBody] bodyCambiarContraAdmin body)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 9);
|
||||
if (!ret) return BadRequest(new { message = "No tienes permisos para cambiar contraseñas de usuario" });
|
||||
|
||||
if (body.contraseña.Length < 8 || string.IsNullOrWhiteSpace(body.contraseña)) return BadRequest(new { message = "La contraseña debe tener al menos 8 caracteres y no puede estar vacía" });
|
||||
|
||||
if (body.Dni <= 0) return BadRequest(new { message = "El DNI no puede estar vacío" });
|
||||
|
||||
Cliente? usu = RepositorioUsuarios.Singleton.ObtenerClientePorDni(body.Dni);
|
||||
if (usu == null) return BadRequest(new { message = "No existe un usuario con ese DNI" });
|
||||
|
||||
ret = RepositorioUsuarios.Singleton.CambiarContraseña(body.contraseña, usu);
|
||||
return ret ? Ok(new { message = "Contraseña cambiada con éxito" }) : BadRequest(new { message = "No se pudo cambiar la contraseña" });
|
||||
|
||||
}
|
||||
|
||||
public record SetEmail(string EmailRecuperacion);
|
||||
[HttpPut("/api/usuario/emailrecuperacion")]
|
||||
public IActionResult CambiarPass([FromHeader(Name = "Auth")] string Auth, [FromBody] SetEmail setemail)
|
||||
{
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un usuario por ese token" });
|
||||
|
||||
string emailrecuperacion = setemail.EmailRecuperacion;
|
||||
if (!emailrecuperacion.Contains("@")) return BadRequest(new { message = "Tiene que ser un email" });
|
||||
|
||||
bool ret = RepositorioUsuarios.Singleton.SetEmailRecuperacion(emailrecuperacion, cli);
|
||||
if (ret == false) return BadRequest(new { message = "No se pudo actualizar el email de recuperación" });
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
AvisoEmailSender s = new();
|
||||
s.Send(cli.Email, setemail.EmailRecuperacion);
|
||||
});
|
||||
|
||||
return Ok(new { message = "Email de recuperación actualizado con éxito" });
|
||||
}
|
||||
|
||||
public record RecuperarUsuarioDto(string Email, string EmailRecuperacion);
|
||||
[HttpPost("/api/recuperarUsuario")]
|
||||
public IActionResult RecuperarUsuario([FromBody] RecuperarUsuarioDto mails)
|
||||
{
|
||||
bool check = RepositorioUsuarios.Singleton.CheckEmailRecuperacion(mails.Email, mails.EmailRecuperacion);
|
||||
if (check == false) return BadRequest(new { message = "El email no corresponde al email de recuperacion" });
|
||||
|
||||
string pin = "";
|
||||
var ran = new Random();
|
||||
for (int i = 0; i < 6; i++) pin += ran.Next(0, 10);
|
||||
|
||||
bool ret = RepositorioUsuarios.Singleton.SetF2aPin(pin, mails.Email);
|
||||
if (ret == false) return BadRequest(new { message = "no se pudo generar/guardar el codigo 2fa" });
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
OtpEmailSender s = new();
|
||||
s.Send(mails.EmailRecuperacion, mails.Email, pin);
|
||||
});
|
||||
|
||||
return Ok(new { message = $"Se envio un email de recuperacion a {mails.EmailRecuperacion}" });
|
||||
}
|
||||
|
||||
public record ingreso2fa(string Pin, string Email);
|
||||
[HttpPost("/api/ingresar2fa")]
|
||||
public IActionResult IngresarUsuario([FromBody] ingreso2fa data)
|
||||
{
|
||||
if (!data.Email.Contains("@")) return BadRequest(new { message = "Tiene que ser un email" });
|
||||
if (data.Pin.Length != 6) return BadRequest(new { message = "el pin tiene que tener 6 digitos" });
|
||||
|
||||
(bool check, long Dni) = RepositorioUsuarios.Singleton.Check2fa(data.Email, data.Pin);
|
||||
if (check == false) return BadRequest(new { message = "El pin es incorrecto" });
|
||||
|
||||
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorDni(Dni);
|
||||
|
||||
//esto literalmente no se puede triggerear pero lo pongo para evitar una warning
|
||||
if (cli == null) return BadRequest(new { message = "El usuario no existe" });
|
||||
|
||||
return Ok(new { token = cli.Token });
|
||||
}
|
||||
|
||||
public record Crearusuario(long Dni, string Nombre, string Apellido, string Domicilio, string Celular,
|
||||
string Email, string Contraseña, string? EmailRecuperacion, List<int> grupos);
|
||||
[HttpPost("api/crearusuario")]
|
||||
public IActionResult CrearUsuario([FromHeader(Name ="Auth")] string Auth, [FromBody] Crearusuario cu)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 19);
|
||||
if (!ret) return BadRequest(new { message = "No tienes permisos para Crear un usuario" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un usuario por ese token" });
|
||||
|
||||
string rett = "";
|
||||
|
||||
if (cu.Dni <= 0)
|
||||
rett += "No puede haber un documento con numero menor o igual a 0";
|
||||
if (cu.Apellido.Length > 20)
|
||||
rett += "Apellido excede los 20 caracteres. ";
|
||||
if (cu.Nombre.Length > 20)
|
||||
rett += "Nombre excede los 20 caracteres. ";
|
||||
if (cu.Celular.Length > 40)
|
||||
rett += "Celular excede los 40 caracteres. ";
|
||||
if (cu.Domicilio.Length > 40)
|
||||
rett += "Domicilio excede los 40 caracteres. ";
|
||||
if (cu.Email.Length > 50)
|
||||
rett += "Email excede los 50 caracteres. ";
|
||||
if (cu.EmailRecuperacion?.Length > 50)
|
||||
rett += "Email de recuperación excede los 50 caracteres. ";
|
||||
|
||||
if (rett != "") return BadRequest(new { message = rett });
|
||||
|
||||
Cliente clii = new Cliente
|
||||
{
|
||||
Habilitado = 1,
|
||||
Dni = cu.Dni,
|
||||
Nombre = cu.Nombre,
|
||||
Apellido = cu.Apellido,
|
||||
Celular = cu.Celular,
|
||||
Email = cu.Email,
|
||||
EmailRecuperacion = ((cu.EmailRecuperacion ?? "").Length == 0) ? cu.Email : cu.EmailRecuperacion,
|
||||
Domicilio = cu.Domicilio
|
||||
};
|
||||
|
||||
var rettt = RepositorioUsuarios.Singleton.AltaUsuario(cli.Dni, clii, cu.Contraseña, cu.grupos);
|
||||
|
||||
return rettt
|
||||
? Ok(new { message = "Usuario creado exitosamente." })
|
||||
: BadRequest(new { message = "Hubo un error al crear el usuario." }); }
|
||||
}
|
||||
475
Aspnet/Controllers/VentaController.cs
Normal file
475
Aspnet/Controllers/VentaController.cs
Normal file
@@ -0,0 +1,475 @@
|
||||
using System.Text.Json;
|
||||
using AlquilaFacil.Builder;
|
||||
using AlquilaFacil.Config;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
using Modelo;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
[ApiController]
|
||||
public class VentaController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpPost("api/venta/AceptarConsultaVenta")]
|
||||
public IActionResult AceptarConsultaVenta([FromHeader(Name = "Auth")] string Auth, NotificacionMarcarLeidoDto dto)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 15);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
if (dto.Email == "") return BadRequest(new { message = "Falta dato Email" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) Unauthorized();
|
||||
if (cli.Email != dto.Email) return BadRequest(new { message = "El token de autorizacion no corresponde a tu usuario" });
|
||||
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.Fecha);
|
||||
|
||||
Notificacione? n = RepositorioNotificaciones.Singleton.ObtenerNotificacionPorKeys(cli.Dni, dto.Fecha);
|
||||
if (n == null) return BadRequest(new { message = "No se encuentra la notificacion" });
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(n.Idpropiedad);
|
||||
if (prop == null) return BadRequest(new { message = "No se encuentra una propiedad por ese id" });
|
||||
Venta? v = new Venta
|
||||
{
|
||||
Fechainicio = DateTime.Now,
|
||||
IdVendedor = prop.Dnipropietario,
|
||||
IdComprador = n.Dniremitente,
|
||||
Monto = prop.Monto,
|
||||
Idpropiedad = prop.Id,
|
||||
Iddivisa = prop.Iddivisa,
|
||||
Idestado = 2,
|
||||
|
||||
};
|
||||
|
||||
bool ret = RepositorioVentas.Singleton.IniciarVenta(v, cli.Dni);
|
||||
if (ret)
|
||||
{
|
||||
var noti = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion")
|
||||
.SetMensaje("Debe Realizar el pago para que se registre el traspaso de la propiedad")
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(n.Dniremitente)
|
||||
.SetDniremitente(n.Dnicliente)
|
||||
.SetIdpropiedad(n.Idpropiedad)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||
}
|
||||
return ret ?
|
||||
Ok(new { message = "Se inicio la venta" }) : BadRequest(new { message = "fallo al iniciar la venta" });
|
||||
}
|
||||
|
||||
[HttpPost("api/venta/CancelarConsultaVenta")]
|
||||
public IActionResult CancelarConsultaVenta([FromHeader(Name = "Auth")] string Auth, NotificacionMarcarLeidoDto dto)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 15);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (dto.Email == "") return BadRequest(new { message = "Falta dato Email" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) Unauthorized();
|
||||
if (cli.Email != dto.Email) return BadRequest(new { message = "El token de autorizacion no corresponde a tu usuario" });
|
||||
|
||||
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.Fecha);
|
||||
Notificacione? n = RepositorioNotificaciones.Singleton.ObtenerNotificacionPorKeys(cli.Dni, dto.Fecha);
|
||||
var noti = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion")
|
||||
.SetMensaje("El propietario no quiere vender")
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(n.Dniremitente)
|
||||
.SetDniremitente(n.Dnicliente)
|
||||
.SetIdpropiedad(n.Idpropiedad)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
|
||||
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||
return ret ?
|
||||
Ok(new { message = "Se Envio una notificacion" }) : BadRequest(new { message = "Fallo al Descartar Consulta" });
|
||||
}
|
||||
|
||||
[HttpPut("/api/propiedad/setPropiedadAVenta")]
|
||||
public IActionResult setPropiedadAVenta([FromHeader(Name = "Auth")] string Auth, SetVentaDto dto)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
var validacion2 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
||||
if (validacion1 == false || validacion2 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (dto.iddivisa != 0 && dto.iddivisa != 1) return BadRequest(new { message = "no hay una divisa por esa id" });
|
||||
if (dto.idpropiedad <= 0) return BadRequest(new { message = "No hay propiedades con id 0 o menor" });
|
||||
if (dto.monto < 1) return BadRequest(new { message = "No se pueden hacer ventas por montos menores a 1" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.idpropiedad);
|
||||
if (prop == null) return BadRequest(new { message = "No hay propiedades por ese id" });
|
||||
|
||||
if (cli.Dni != prop.Dnipropietario) return Unauthorized();
|
||||
|
||||
var ret = RepositorioVentas.Singleton.SetVenta(prop.Id, dto.monto, dto.iddivisa, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se puso la propiedad de venta" }) : BadRequest(new { message = "No se pudo poner a la Venta" });
|
||||
}
|
||||
|
||||
[HttpPut("/api/propiedad/unsetPropiedadAVenta")]
|
||||
public IActionResult unsetPropiedadAVenta([FromHeader(Name = "Auth")] string Auth, SetVentaDto dto)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 15);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (dto.iddivisa != 0 && dto.iddivisa != 1) return BadRequest(new { message = "no hay una divisa por esa id" });
|
||||
if (dto.idpropiedad <= 0) return BadRequest(new { message = "No hay propiedades con id 0 o menor" });
|
||||
if (dto.monto < 1) return BadRequest(new { message = "No se pueden hacer ventas por montos menores a 1" });
|
||||
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.idpropiedad);
|
||||
if (prop == null) return BadRequest(new { message = "No hay propiedades por ese id" });
|
||||
|
||||
if (cli.Dni != prop.Dnipropietario) return Unauthorized();
|
||||
|
||||
bool ret = RepositorioVentas.Singleton.UnSetVenta(prop.Id, dto.monto, dto.iddivisa, cli.Dni);
|
||||
|
||||
return ret ?
|
||||
Ok(new { message = "Se Bajo la propiedad de venta" }) : BadRequest(new { message = "No se pudo Bajar de venta" });
|
||||
}
|
||||
|
||||
[HttpPost("/api/ventas/ejercerOpcionVenta")]
|
||||
public IActionResult EjercerOpcionVenta([FromHeader(Name = "Auth")] string Auth, [FromQuery] long idcontrato = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
if (idcontrato <= 0) return BadRequest(new { message = "No pueden hacer cotratos con id 0 o menor" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioVentas.Singleton.ObtenerVentaPorContrato(idcontrato);
|
||||
if (cont == null || cont.IdventaNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id" });
|
||||
if (cont.Tieneopcionventa == 0) return BadRequest(new { message = "No tiene opcion de venta" });
|
||||
if (puedeEjercer(cont) == false) return BadRequest(new { message = "No cumple con los requisitos para ejercer la opcion de compra" });
|
||||
|
||||
Venta venta = cont.IdventaNavigation;
|
||||
venta.IdVendedor = cont.Dnipropietario;
|
||||
venta.IdComprador = cont.Dniinquilino;
|
||||
venta.Idpropiedad = cont.Idpropiedad;
|
||||
venta.Fechainicio = DateTime.Now;
|
||||
|
||||
bool ret = RepositorioVentas.Singleton.PatchVenta(venta, cli.Dni);
|
||||
|
||||
return ret ?
|
||||
Ok(new { message = "Se ejercio la opcion de venta" }) :
|
||||
BadRequest(new { message = "No se pude ejercer la opcion de venta" });
|
||||
}
|
||||
|
||||
[HttpPost("/api/ventas/subirReciboPago")]
|
||||
public async Task<IActionResult> SubirRecibo([FromHeader(Name = "Auth")] string Auth, IFormFile file, long idventa)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (idventa <= 0) return BadRequest(new { message = "Las id 0 o menor no son validas" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Venta? venta = RepositorioVentas.Singleton.ObtenerVentaPorId(idventa);
|
||||
if (venta == null) return BadRequest(new { message = "no hay una venta por esa id" });
|
||||
|
||||
if (cli.Dni != venta.IdComprador && cli.Dni != venta.IdVendedor) return Unauthorized();
|
||||
|
||||
if (file == null) return BadRequest(new { message = "Debe subir un archivo." });
|
||||
if (file.ContentType != "application/pdf") return BadRequest(new { message = "El archivo debe ser un documento PDF." });
|
||||
if (!Path.GetExtension(file.FileName).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) return BadRequest(new { message = "El archivo debe tener la extensión .pdf." });
|
||||
|
||||
string nuevoNombreArchivo = $"id:{venta.Id}-comprador:{venta.IdComprador}-vendedor:{venta.IdVendedor}-idprop:{venta.Idpropiedad}.pdf";
|
||||
bool ret = await subirContrato(file, nuevoNombreArchivo);
|
||||
if (ret == false) return BadRequest(new { message = "No se pudo subir el archivo" });
|
||||
|
||||
ret = RepositorioVentas.Singleton.SetUrlRecibo(venta.Id, nuevoNombreArchivo, cli.Dni);
|
||||
if (ret == false) return BadRequest(new { message = "no se pudo guardar el nombre del archivo subido" });
|
||||
|
||||
return Ok(new { message = "Se Subio el Recibo" });
|
||||
|
||||
}
|
||||
private readonly IMinioClient mc;
|
||||
public VentaController(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("0.0.0.0:9000")
|
||||
.WithSSL(false)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("/api/ventas/verRecibo")]
|
||||
public IActionResult verRecibo([FromHeader(Name = "Auth")] string Auth, long idventa = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
if (idventa <= 0) return BadRequest(new { message = "No existen ventas validas para la id 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Venta? venta = RepositorioVentas.Singleton.ObtenerVentaPorId(idventa);
|
||||
if (venta == null) return BadRequest(new { message = "no hay una venta con esa id" });
|
||||
if (cli.Dni != venta.IdComprador && cli.Dni != venta.IdVendedor) return Unauthorized();
|
||||
|
||||
try
|
||||
{
|
||||
var memstream = new MemoryStream();
|
||||
|
||||
var goa = new GetObjectArgs()
|
||||
.WithBucket("alquilafacil")
|
||||
.WithObject(venta.UrlRecibo)
|
||||
.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", venta.UrlRecibo);
|
||||
|
||||
}
|
||||
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/ventas/propietarioverifica")]
|
||||
public IActionResult PropietarioVerifica([FromHeader(Name = "Auth")] string Auth, long idventa = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
if (idventa <= 0) return BadRequest(new { message = "No existen ventas validas para la id 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ventas = RepositorioVentas.Singleton.ObtenerVentaPorId(idventa);
|
||||
if (ventas == null) return BadRequest(new { message = "No hay una venta con ese id" });
|
||||
if (ventas.IdVendedor != cli.Dni) return Unauthorized();
|
||||
|
||||
bool ret = RepositorioVentas.Singleton.EfectuarVenta(idventa);
|
||||
return ret ? Ok(new { message = "Se traspaso la propiedad" }) : BadRequest(new { message = "" });
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("/api/venta")]
|
||||
public IActionResult ObtenerVenta([FromHeader(Name = "Auth")] string Auth, long idventa = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
|
||||
if (idventa <= 0) return BadRequest(new { message = "No existen ventas validas para la id 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ventas = RepositorioVentas.Singleton.ObtenerVentaPorId(idventa);
|
||||
if (ventas == null) return BadRequest(new { message = "No hay una venta con ese id" });
|
||||
if (ventas.IdVendedor != cli.Dni && ventas.IdComprador != cli.Dni) return Unauthorized();
|
||||
|
||||
var v = new VentasDtoBuilder()
|
||||
.SetId(ventas.Id)
|
||||
.SetMonto(ventas.Monto)
|
||||
.SetDivisa(ventas.IddivisaNavigation.Signo)
|
||||
.SetUbicacion(ventas.IdpropiedadNavigation.Ubicacion)
|
||||
.SetNombreVendedor($"{ventas.IdVendedorNavigation.Nombre} {ventas.IdVendedorNavigation.Apellido}")
|
||||
.SetIdVendedor(ventas.IdVendedor ?? 0)
|
||||
.SetNombreComprador($"{ventas.IdCompradorNavigation.Nombre} {ventas.IdCompradorNavigation.Apellido}")
|
||||
.SetIdComprador(ventas.IdComprador ?? 0)
|
||||
.SetEstado(ventas.IdestadoNavigation.Descripcion ?? "")
|
||||
.Build();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
data = v,
|
||||
iscomprador = (ventas.IdComprador == cli.Dni) ? true : false,
|
||||
necesitaRecibo = ventas.UrlRecibo == null ? true : false
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/api/ventas")]
|
||||
public IActionResult ObtenerVentas([FromHeader(Name = "Auth")] string Auth)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
var ventas = RepositorioVentas.Singleton.ObtenerVentasPorDni(cli.Dni);
|
||||
if (ventas == null) return BadRequest(new { message = "no estas involucrado en ninguna venta o compra" });
|
||||
|
||||
List<VentasDto> lista = new();
|
||||
foreach (var i in ventas)
|
||||
{
|
||||
var v = new VentasDtoBuilder()
|
||||
.SetId(i.Id)
|
||||
.SetMonto(i.Monto)
|
||||
.SetDivisa(i.IddivisaNavigation.Signo)
|
||||
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||
.SetNombreVendedor($"{i.IdVendedorNavigation.Nombre} {i.IdVendedorNavigation.Apellido}")
|
||||
.SetIdVendedor(i.IdVendedor ?? 0)
|
||||
.SetNombreComprador($"{i.IdCompradorNavigation.Nombre} {i.IdCompradorNavigation.Apellido}")
|
||||
.SetIdComprador(i.IdComprador ?? 0)
|
||||
.SetEstado(i.IdestadoNavigation.Descripcion ?? "")
|
||||
.Build();
|
||||
lista.Add(v);
|
||||
}
|
||||
return Ok(lista);
|
||||
}
|
||||
|
||||
[HttpGet("/api/opcionventa")]
|
||||
public IActionResult ObtenerDto([FromHeader(Name = "Auth")] string Auth, long idcontrato = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
if (idcontrato == 0) return BadRequest(new { message = "No existen contatos validos para la id 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioVentas.Singleton.ObtenerVentaPorContrato(idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id" });
|
||||
|
||||
var dto = new OpcionVentaDtoBuilder()
|
||||
.SetId(cont.Idventa ?? 0)
|
||||
.SetMonto(cont.IdventaNavigation.Monto)
|
||||
.SetDivisa(cont.IdventaNavigation.IddivisaNavigation.Signo)
|
||||
.SetEnOrden(puedeEjercer(cont))
|
||||
.SetFueEjercido(cont.IdventaNavigation.Idestado ?? 0)
|
||||
.Build();
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
|
||||
private bool puedeEjercer(Contrato c)
|
||||
{
|
||||
bool ret = c.Idcanons.All(x => x.Pagado == 1);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
var canonConFechaMasTardia = c.Idcanons.OrderByDescending(x => x.Fecha).FirstOrDefault();
|
||||
|
||||
if (canonConFechaMasTardia != null && canonConFechaMasTardia.Fecha.Year >= DateTime.Now.Year
|
||||
&& canonConFechaMasTardia.Fecha.Month >= DateTime.Now.Month)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[HttpGet("/api/contrato/tieneopcionventa")]
|
||||
public IActionResult TieneOpcionVenta([FromHeader(Name = "Auth")] string Auth, long idcontrato = 0)
|
||||
{
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
if (idcontrato == 0) return BadRequest(new { message = "No existen contatos validos para la id 0" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id" });
|
||||
if (cont.Dniinquilino != cli.Dni && cont.Dnipropietario != cli.Dni) return Unauthorized();
|
||||
|
||||
return Ok(new { message = cont.Tieneopcionventa });
|
||||
}
|
||||
}
|
||||
38
Aspnet/Emailer/Builder/EmailBuilder.cs
Normal file
38
Aspnet/Emailer/Builder/EmailBuilder.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Net.Mail;
|
||||
namespace AlquilaFacil.Emailer.Builder;
|
||||
|
||||
public class EmailBuilder
|
||||
{
|
||||
private MailMessage _message = new();
|
||||
|
||||
public EmailBuilder To(string to)
|
||||
{
|
||||
_message.To.Add(to);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmailBuilder Subject(string subject)
|
||||
{
|
||||
_message.Subject = subject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmailBuilder Body(string email, string pin, string modo = "2fa")
|
||||
{
|
||||
_message.IsBodyHtml = true;
|
||||
switch (modo)
|
||||
{
|
||||
case "2fa":
|
||||
_message.Body = new HtmlGenerator().GenerarMail2fa(email, pin);
|
||||
break;
|
||||
case "aviso":
|
||||
_message.Body = new HtmlGenerator().AvisoSetEmail(email, pin);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MailMessage Build() => _message;
|
||||
}
|
||||
112
Aspnet/Emailer/Builder/EmailHtmlGenerator.cs
Normal file
112
Aspnet/Emailer/Builder/EmailHtmlGenerator.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
namespace AlquilaFacil.Emailer.Builder;
|
||||
|
||||
public class HtmlGenerator
|
||||
{
|
||||
public string GenerarMail2fa(string emailUsuario, string pin)
|
||||
{
|
||||
var msg = $"""
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<div
|
||||
style='background-color:#000000;color:#FFFFFF;font-family:"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
|
||||
>
|
||||
<table
|
||||
align="center"
|
||||
width="100%"
|
||||
style="margin:0 auto;max-width:600px;background-color:#000000"
|
||||
role="presentation"
|
||||
cellspacing="0"
|
||||
cellpadding="0"
|
||||
border="0"
|
||||
>
|
||||
<tbody>
|
||||
<tr style="width:100%">
|
||||
<td>
|
||||
<div
|
||||
style="color:#ffffff;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Aqui esta su codigo OTP:
|
||||
</div>
|
||||
<h1
|
||||
style='font-weight:bold;text-align:center;margin:0;font-family:"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace;font-size:32px;padding:16px 24px 16px 24px'
|
||||
>
|
||||
{pin}
|
||||
</h1>
|
||||
<div
|
||||
style="color:#868686;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Este codigo es del usuario con email:{emailUsuario}
|
||||
</div>
|
||||
<div
|
||||
style="color:#868686;font-size:14px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Si no sabes para que es el email, ignoralo.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
""";
|
||||
|
||||
return msg;
|
||||
}
|
||||
public string AvisoSetEmail(string emailUsuario, string emailreq)
|
||||
{
|
||||
var msg = $"""
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<div
|
||||
style='background-color:#000000;color:#FFFFFF;font-family:"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
|
||||
>
|
||||
<table
|
||||
align="center"
|
||||
width="100%"
|
||||
style="margin:0 auto;max-width:600px;background-color:#000000"
|
||||
role="presentation"
|
||||
cellspacing="0"
|
||||
cellpadding="0"
|
||||
border="0"
|
||||
>
|
||||
<tbody>
|
||||
<tr style="width:100%">
|
||||
<td>
|
||||
<div
|
||||
style="color:#ffffff;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Aviso:
|
||||
</div>
|
||||
<h1
|
||||
style='font-weight:bold;text-align:center;margin:0;font-family:"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace;font-size:32px;padding:16px 24px 16px 24px'
|
||||
>
|
||||
Se seteo este email : {emailreq}, como email de respaldo
|
||||
</h1>
|
||||
<div
|
||||
style="color:#868686;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
|
||||
</div>
|
||||
<div
|
||||
style="color:#868686;font-size:14px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Si no sabes para que es el email, ignoralo.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
""";
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
11
Aspnet/Emailer/Decorator/AvisoEmailSender.cs
Normal file
11
Aspnet/Emailer/Decorator/AvisoEmailSender.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AlquilaFacil.Emailer.Sender;
|
||||
using AlquilaFacil.Emailer.Builder;
|
||||
|
||||
public class AvisoEmailSender : EmailSender
|
||||
{
|
||||
public void Send(string emailusu, string emailreq)
|
||||
{
|
||||
var mail = new EmailBuilder().Body(emailusu, emailreq, "aviso").To(emailreq).Subject("AvisoEmail").Build();
|
||||
base.Send(mail);
|
||||
}
|
||||
}
|
||||
50
Aspnet/Emailer/Decorator/EmailerSender.cs
Normal file
50
Aspnet/Emailer/Decorator/EmailerSender.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AlquilaFacil.Emailer.Sender;
|
||||
|
||||
public class EmailSender
|
||||
{
|
||||
protected static SmtpClient? smtp = null;
|
||||
protected void configSmtp(MailMessage mail)
|
||||
{
|
||||
var jsonContent = File.ReadAllText("settings.json");
|
||||
var options = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonContent);
|
||||
if (options == null) return;
|
||||
|
||||
|
||||
bool check = options.ContainsKey("smtpHost");
|
||||
check = options.ContainsKey("smtpPort");
|
||||
check = options.ContainsKey("emailAddr");
|
||||
check = options.ContainsKey("emailPass");
|
||||
|
||||
if (check == false) return;
|
||||
mail.Sender = new MailAddress(options["emailAddr"]);
|
||||
mail.From = new MailAddress(options["emailAddr"]);
|
||||
|
||||
if (null != smtp) return;
|
||||
smtp = new();
|
||||
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
smtp.EnableSsl = true;
|
||||
smtp.Host = options["smtpHost"];
|
||||
smtp.Port = int.Parse(options["smtpPort"].ToString());
|
||||
smtp.Credentials = new NetworkCredential(options["emailAddr"], options["emailPass"]);
|
||||
}
|
||||
|
||||
public virtual void Send(MailMessage message)
|
||||
{
|
||||
configSmtp(message);
|
||||
if (smtp == null) return;
|
||||
try
|
||||
{
|
||||
smtp.Send(message);
|
||||
message.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
13
Aspnet/Emailer/Decorator/OtpEmailSender.cs
Normal file
13
Aspnet/Emailer/Decorator/OtpEmailSender.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace AlquilaFacil.Emailer.Sender;
|
||||
using AlquilaFacil.Emailer.Builder;
|
||||
public class OtpEmailSender : EmailSender
|
||||
{
|
||||
|
||||
public void Send(string To, string email, string pin)
|
||||
{
|
||||
var mail = new EmailBuilder().To(To).Body(email, pin).Subject("Mail de Recuperacion").Build();
|
||||
|
||||
base.Send(mail);
|
||||
|
||||
}
|
||||
}
|
||||
24
Aspnet/Facade/DocumentoFacade.cs
Normal file
24
Aspnet/Facade/DocumentoFacade.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
|
||||
public class DocumentoFacade {
|
||||
private readonly DocumentoGeneradorHtml d1 = new();
|
||||
private readonly DocumentoGeneradorPdf d2 = new();
|
||||
|
||||
public void GenerarHtml(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
|
||||
string str = d1.GenerarHTML(cd, r);
|
||||
StreamWriter writer = new StreamWriter(memoryStream, Encoding.UTF8);
|
||||
writer.WriteAsync(str).Wait();
|
||||
writer.FlushAsync().Wait();
|
||||
memoryStream.Position = 0;
|
||||
}
|
||||
public void GenerarPdf(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
|
||||
var mem = d2.GenerarPdf(cd, r);
|
||||
mem.CopyToAsync(memoryStream).Wait();
|
||||
memoryStream.Position = 0;
|
||||
}
|
||||
}
|
||||
45
Aspnet/Facade/DocumentoGeneradorHtml.cs
Normal file
45
Aspnet/Facade/DocumentoGeneradorHtml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Routing.Template;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
public class DocumentoGeneradorHtml {
|
||||
public string GenerarHTML(ContratoDto cd, Recibo r) {
|
||||
string tmpl =$"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
AlquilaFácil
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Detalles</h5>
|
||||
<p class="card-text">
|
||||
<strong>ID:</strong> {cd.id}<br>
|
||||
<strong>Ubicación:</strong> {cd.Ubicacion}<br>
|
||||
<strong>Tipo de Propiedad:</strong> {cd.TipoPropiedad}<br>
|
||||
<strong>Fecha de Inicio:</strong> {cd.Fechainicio}<br>
|
||||
<strong>Inquilino:</strong> {cd.Inquilino}<br>
|
||||
<strong>Propietario:</strong> {cd.Propietario}<br>
|
||||
</p>
|
||||
<hr>
|
||||
<h5 class="card-title">Detalles del Recibo</h5>
|
||||
<p class="card-text">
|
||||
<strong>ID del Recibo:</strong> {r.Id}<br>
|
||||
<strong>Fecha:</strong> {r.Fecha}<br>
|
||||
<strong>Monto:</strong> {r.Monto}<br>
|
||||
<h2><b>PAGO</b></h2>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""; return tmpl;
|
||||
}
|
||||
}
|
||||
67
Aspnet/Facade/DocumentoGeneradorPdf.cs
Normal file
67
Aspnet/Facade/DocumentoGeneradorPdf.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
using System.IO;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
public class DocumentoGeneradorPdf {
|
||||
public MemoryStream GenerarPdf(ContratoDto cd, Recibo r)
|
||||
{
|
||||
var pdfStream = new MemoryStream();
|
||||
QuestPDF.Settings.License = LicenseType.Community;
|
||||
Document.Create(container =>
|
||||
{
|
||||
container.Page(page =>
|
||||
{
|
||||
page.Size(PageSizes.A4);
|
||||
page.Margin(2, Unit.Centimetre);
|
||||
page.Header().Text("AlquilaFácil").FontSize(20).SemiBold().FontColor(Colors.White);
|
||||
page.Content().Column(column =>
|
||||
{
|
||||
column.Spacing(10);
|
||||
|
||||
column.Item().Border(1).Padding(10).Column(card =>
|
||||
{
|
||||
card.Item().Row(row =>
|
||||
{
|
||||
row.RelativeItem().Text("Detalles").FontSize(16).SemiBold();
|
||||
});
|
||||
|
||||
card.Item().Column(body =>
|
||||
{
|
||||
body.Spacing(5);
|
||||
body.Item().Text($"ID: {cd.id}").FontSize(12).Bold();
|
||||
body.Item().Text($"Ubicación: {cd.Ubicacion}").FontSize(12);
|
||||
body.Item().Text($"Tipo de Propiedad: {cd.TipoPropiedad}").FontSize(12);
|
||||
body.Item().Text($"Fecha de Inicio: {cd.Fechainicio}").FontSize(12);
|
||||
body.Item().Text($"Inquilino: {cd.Inquilino}").FontSize(12);
|
||||
body.Item().Text($"Propietario: {cd.Propietario}").FontSize(12);
|
||||
});
|
||||
});
|
||||
|
||||
column.Item().Border(1).Padding(10).Column(card =>
|
||||
{
|
||||
card.Item().Row(row =>
|
||||
{
|
||||
row.RelativeItem().Text("Detalles del Recibo").FontSize(16).SemiBold();
|
||||
});
|
||||
|
||||
card.Item().Column(body =>
|
||||
{
|
||||
body.Spacing(5);
|
||||
body.Item().Text($"ID del Recibo: {r.Id}").FontSize(12).Bold();
|
||||
body.Item().Text($"Fecha: {r.Fecha}").FontSize(12);
|
||||
body.Item().Text($"Monto: {r.Monto}").FontSize(12);
|
||||
body.Item().AlignCenter().Text("PAGO").FontSize(20).Bold();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}).GeneratePdf(pdfStream);
|
||||
|
||||
pdfStream.Position = 0;
|
||||
return pdfStream;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,29 @@
|
||||
|
||||
using System.Text.Json;
|
||||
using Minio;
|
||||
using AlquilaFacil.Config;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
MinioConfigcus? mcon = JsonSerializer.Deserialize<MinioConfigcus>(File.ReadAllText("./settings.json"))?? null;
|
||||
if (mcon == null) return;
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddMinio(options => options
|
||||
.WithCredentials(mcon.usr, mcon.scrt)
|
||||
.WithEndpoint("127.0.0.0:9000")
|
||||
.WithSSL(false)
|
||||
.Build());
|
||||
|
||||
builder.Services.Configure<FormOptions>(options =>
|
||||
{
|
||||
options.MultipartBodyLengthLimit = 50 * 1024 * 1024; // 50 MB
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
@@ -16,6 +35,15 @@ builder.Services.AddCors(options =>
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
});
|
||||
|
||||
options.AddPolicy("AllowSvelteAppv6",
|
||||
builder =>
|
||||
{
|
||||
builder.WithOrigins("http://[::1]:5173")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
9
Aspnet/bin/Debug/net8.0/settings.json
Normal file
9
Aspnet/bin/Debug/net8.0/settings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usr": "nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
||||
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none",
|
||||
"smtpHost": "smtp.gmail.com",
|
||||
"smtpPort": "587",
|
||||
"emailAddr": "emailerpasillo@gmail.com",
|
||||
"emailPass": "hgwa mznx xuff exws"
|
||||
}
|
||||
9
Aspnet/settings.json
Normal file
9
Aspnet/settings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usr": "nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
||||
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none",
|
||||
"smtpHost": "smtp.gmail.com",
|
||||
"smtpPort": "587",
|
||||
"emailAddr": "emailerpasillo@gmail.com",
|
||||
"emailPass": "hgwa mznx xuff exws"
|
||||
}
|
||||
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/NotificarAdmin.cs
Normal file
6
Entidades/Admin/NotificarAdmin.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Entidades.Admin;
|
||||
public class NotificarAdmin {
|
||||
public string Mensaje { get; set; }="";
|
||||
public long Idcontrato{get;set;}
|
||||
public long Idcanon {get; set;}
|
||||
}
|
||||
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;} = "";
|
||||
}
|
||||
13
Entidades/Admin/PropiedadesAdmin.cs
Normal file
13
Entidades/Admin/PropiedadesAdmin.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
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; } = "";
|
||||
public int Iddivisa { get; set; }
|
||||
}
|
||||
8
Entidades/Admin/UpdateUsuarioAdmin.cs
Normal file
8
Entidades/Admin/UpdateUsuarioAdmin.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entidades.Admin;
|
||||
public class UpdateUsuarioAdmin {
|
||||
public string Nombre { get; set; } = null!;
|
||||
public string Apellido { get; set; } = null!;
|
||||
public string Domicilio { get; set; } = null!;
|
||||
public string Celular { get; set; } = null!;
|
||||
|
||||
}
|
||||
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; }
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Entidades;
|
||||
@@ -23,6 +25,8 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
public virtual DbSet<Defecto> Defectos { get; set; }
|
||||
|
||||
public virtual DbSet<Divisa> Divisas { get; set; }
|
||||
|
||||
public virtual DbSet<EstadoPropiedad> EstadoPropiedads { get; set; }
|
||||
|
||||
public virtual DbSet<Estadodefecto> Estadodefectos { get; set; }
|
||||
@@ -33,6 +37,12 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
public virtual DbSet<Grupo> Grupos { get; set; }
|
||||
|
||||
public virtual DbSet<Log> Logs { get; set; }
|
||||
|
||||
public virtual DbSet<LogDetalle> LogDetalles { get; set; }
|
||||
|
||||
public virtual DbSet<Notificacione> Notificaciones { get; set; }
|
||||
|
||||
public virtual DbSet<Permiso> Permisos { get; set; }
|
||||
|
||||
public virtual DbSet<Propiedade> Propiedades { get; set; }
|
||||
@@ -46,9 +56,29 @@ public partial class AlquilaFacilContext : DbContext
|
||||
public virtual DbSet<Venta> Ventas { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
||||
=> optionsBuilder.UseMySQL("Server=fedesrv.ddns.net;Port=30006;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none");
|
||||
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonContent = File.ReadAllText("settings.json");
|
||||
var options = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonContent);
|
||||
if (options != null && options.ContainsKey("connectiondb"))
|
||||
{
|
||||
optionsBuilder.UseMySQL(options["connectiondb"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("No se encontró la clave 'connectiondb' en el archivo settings.json");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error al configurar la conexión a la base de datos: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Canon>(entity =>
|
||||
@@ -103,6 +133,12 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Email)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("email");
|
||||
entity.Property(e => e.EmailRecuperacion)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("emailRecuperacion");
|
||||
entity.Property(e => e.F2a)
|
||||
.HasMaxLength(6)
|
||||
.HasColumnName("f2a");
|
||||
entity.Property(e => e.Habilitado)
|
||||
.HasDefaultValueSql("b'1'")
|
||||
.HasColumnType("bit(1)")
|
||||
@@ -151,9 +187,14 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
entity.HasIndex(e => e.Idventa, "FK_CON_VEN");
|
||||
|
||||
entity.HasIndex(e => e.Iddivisa, "FK_contdiv");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Cancelado)
|
||||
.HasColumnType("bit(1)")
|
||||
.HasColumnName("cancelado");
|
||||
entity.Property(e => e.Cantgarantemin)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("cantgarantemin");
|
||||
@@ -169,6 +210,9 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Habilitado)
|
||||
.HasColumnType("bit(1)")
|
||||
.HasColumnName("habilitado");
|
||||
entity.Property(e => e.Iddivisa)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("iddivisa");
|
||||
entity.Property(e => e.Idpropiedad)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("idpropiedad");
|
||||
@@ -178,12 +222,17 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Indiceactualizacion)
|
||||
.HasPrecision(8)
|
||||
.HasColumnName("indiceactualizacion");
|
||||
entity.Property(e => e.MesesDurationContrato).HasColumnType("int(11)");
|
||||
entity.Property(e => e.MesesHastaAumento).HasColumnType("int(11)");
|
||||
entity.Property(e => e.Monto)
|
||||
.HasPrecision(12)
|
||||
.HasColumnName("monto");
|
||||
entity.Property(e => e.Tieneopcionventa)
|
||||
.HasColumnType("bit(1)")
|
||||
.HasColumnName("tieneopcionventa");
|
||||
entity.Property(e => e.UrlContrato)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnName("urlContrato");
|
||||
|
||||
entity.HasOne(d => d.DniinquilinoNavigation).WithMany(p => p.ContratoDniinquilinoNavigations)
|
||||
.HasForeignKey(d => d.Dniinquilino)
|
||||
@@ -195,6 +244,11 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_CON_PROPI");
|
||||
|
||||
entity.HasOne(d => d.IddivisaNavigation).WithMany(p => p.Contratos)
|
||||
.HasForeignKey(d => d.Iddivisa)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_contdiv");
|
||||
|
||||
entity.HasOne(d => d.IdpropiedadNavigation).WithMany(p => p.Contratos)
|
||||
.HasForeignKey(d => d.Idpropiedad)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
@@ -240,6 +294,8 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
entity.HasIndex(e => e.Idestado, "FK_DEF_EST");
|
||||
|
||||
entity.HasIndex(e => e.Iddivisa, "FK_defdiv");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("id");
|
||||
@@ -247,11 +303,14 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.HasPrecision(12)
|
||||
.HasColumnName("costo");
|
||||
entity.Property(e => e.Descripcion)
|
||||
.HasMaxLength(40)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnName("descripcion");
|
||||
entity.Property(e => e.Idcontrato)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("idcontrato");
|
||||
entity.Property(e => e.Iddivisa)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("iddivisa");
|
||||
entity.Property(e => e.Idestado)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("idestado");
|
||||
@@ -264,12 +323,29 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_DEF_CON");
|
||||
|
||||
entity.HasOne(d => d.IddivisaNavigation).WithMany(p => p.Defectos)
|
||||
.HasForeignKey(d => d.Iddivisa)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_defdiv");
|
||||
|
||||
entity.HasOne(d => d.IdestadoNavigation).WithMany(p => p.Defectos)
|
||||
.HasForeignKey(d => d.Idestado)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_DEF_EST");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Divisa>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Signo)
|
||||
.HasMaxLength(3)
|
||||
.HasColumnName("signo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<EstadoPropiedad>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
||||
@@ -280,7 +356,7 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Descripcion)
|
||||
.HasMaxLength(11)
|
||||
.HasMaxLength(30)
|
||||
.HasColumnName("descripcion");
|
||||
});
|
||||
|
||||
@@ -312,17 +388,20 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
modelBuilder.Entity<Garante>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Dni).HasName("PRIMARY");
|
||||
entity.HasKey(e => e.Id).HasName("PRIMARY");
|
||||
|
||||
entity.Property(e => e.Dni)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dni");
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Apellido)
|
||||
.HasMaxLength(20)
|
||||
.HasColumnName("apellido");
|
||||
entity.Property(e => e.Celular)
|
||||
.HasMaxLength(40)
|
||||
.HasColumnName("celular");
|
||||
entity.Property(e => e.Dni)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dni");
|
||||
entity.Property(e => e.Domicilio)
|
||||
.HasMaxLength(40)
|
||||
.HasColumnName("domicilio");
|
||||
@@ -333,7 +412,7 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.HasMaxLength(20)
|
||||
.HasColumnName("nombre");
|
||||
|
||||
entity.HasMany(d => d.Idcontratos).WithMany(p => p.Dnigarantes)
|
||||
entity.HasMany(d => d.Idcontratos).WithMany(p => p.Idgarantes)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"ContratoGarante",
|
||||
r => r.HasOne<Contrato>().WithMany()
|
||||
@@ -341,17 +420,17 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_CONGAR_CON"),
|
||||
l => l.HasOne<Garante>().WithMany()
|
||||
.HasForeignKey("Dnigarante")
|
||||
.HasForeignKey("Idgarante")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_CONGAR_GAR"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("Dnigarante", "Idcontrato").HasName("PRIMARY");
|
||||
j.HasKey("Idgarante", "Idcontrato").HasName("PRIMARY");
|
||||
j.ToTable("contrato_garantes");
|
||||
j.HasIndex(new[] { "Idcontrato" }, "FK_CONGAR_CON");
|
||||
j.IndexerProperty<long>("Dnigarante")
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dnigarante");
|
||||
j.IndexerProperty<int>("Idgarante")
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("idgarante");
|
||||
j.IndexerProperty<long>("Idcontrato")
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("idcontrato");
|
||||
@@ -365,9 +444,149 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Habilitado)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("'1'")
|
||||
.HasColumnName("habilitado");
|
||||
entity.Property(e => e.Nombre)
|
||||
.HasMaxLength(12)
|
||||
.HasColumnName("nombre");
|
||||
|
||||
entity.HasMany(d => d.IdGrupoHijos).WithMany(p => p.IdGrupoPadres)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"GrupoSubgrupo",
|
||||
r => r.HasOne<Grupo>().WithMany()
|
||||
.HasForeignKey("IdGrupoHijo")
|
||||
.HasConstraintName("Grupo_Subgrupo_ibfk_2"),
|
||||
l => l.HasOne<Grupo>().WithMany()
|
||||
.HasForeignKey("IdGrupoPadre")
|
||||
.HasConstraintName("Grupo_Subgrupo_ibfk_1"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("IdGrupoPadre", "IdGrupoHijo").HasName("PRIMARY");
|
||||
j.ToTable("Grupo_Subgrupo");
|
||||
j.HasIndex(new[] { "IdGrupoHijo" }, "IdGrupoHijo");
|
||||
j.IndexerProperty<int>("IdGrupoPadre").HasColumnType("int(11)");
|
||||
j.IndexerProperty<int>("IdGrupoHijo").HasColumnType("int(11)");
|
||||
});
|
||||
|
||||
entity.HasMany(d => d.IdGrupoPadres).WithMany(p => p.IdGrupoHijos)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"GrupoSubgrupo",
|
||||
r => r.HasOne<Grupo>().WithMany()
|
||||
.HasForeignKey("IdGrupoPadre")
|
||||
.HasConstraintName("Grupo_Subgrupo_ibfk_1"),
|
||||
l => l.HasOne<Grupo>().WithMany()
|
||||
.HasForeignKey("IdGrupoHijo")
|
||||
.HasConstraintName("Grupo_Subgrupo_ibfk_2"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("IdGrupoPadre", "IdGrupoHijo").HasName("PRIMARY");
|
||||
j.ToTable("Grupo_Subgrupo");
|
||||
j.HasIndex(new[] { "IdGrupoHijo" }, "IdGrupoHijo");
|
||||
j.IndexerProperty<int>("IdGrupoPadre").HasColumnType("int(11)");
|
||||
j.IndexerProperty<int>("IdGrupoHijo").HasColumnType("int(11)");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Log>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Fecha, e.Dniusuario }).HasName("PRIMARY");
|
||||
|
||||
entity.ToTable("Log");
|
||||
|
||||
entity.HasIndex(e => e.Dniusuario, "fk_log_clientes");
|
||||
|
||||
entity.Property(e => e.Fecha)
|
||||
.HasColumnType("datetime")
|
||||
.HasColumnName("fecha");
|
||||
entity.Property(e => e.Dniusuario)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dniusuario");
|
||||
entity.Property(e => e.Accion)
|
||||
.HasMaxLength(255)
|
||||
.HasColumnName("accion");
|
||||
|
||||
entity.HasOne(d => d.DniusuarioNavigation).WithMany(p => p.Logs)
|
||||
.HasForeignKey(d => d.Dniusuario)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("fk_log_clientes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<LogDetalle>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Id, e.Fecha, e.Dniusuario, e.NombreTabla, e.Columna }).HasName("PRIMARY");
|
||||
|
||||
entity.ToTable("LogDetalle");
|
||||
|
||||
entity.HasIndex(e => new { e.Fecha, e.Dniusuario }, "LogDetalle_ibfk_1");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Fecha)
|
||||
.HasColumnType("datetime")
|
||||
.HasColumnName("fecha");
|
||||
entity.Property(e => e.Dniusuario)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dniusuario");
|
||||
entity.Property(e => e.NombreTabla).HasColumnName("nombreTabla");
|
||||
entity.Property(e => e.Columna).HasColumnName("columna");
|
||||
entity.Property(e => e.ValorAnterior)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("valorAnterior");
|
||||
entity.Property(e => e.ValorNuevo)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("valorNuevo");
|
||||
|
||||
entity.HasOne(d => d.Log).WithMany(p => p.LogDetalles)
|
||||
.HasForeignKey(d => new { d.Fecha, d.Dniusuario })
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("LogDetalle_ibfk_1");
|
||||
});
|
||||
|
||||
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 =>
|
||||
@@ -378,7 +597,7 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
entity.Property(e => e.Descripcion)
|
||||
.HasMaxLength(15)
|
||||
.HasMaxLength(25)
|
||||
.HasColumnName("descripcion");
|
||||
|
||||
entity.HasMany(d => d.Idgrupos).WithMany(p => p.Idpermisos)
|
||||
@@ -416,6 +635,8 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
entity.HasIndex(e => e.Idtipropiedad, "FK_PROP_TIPO");
|
||||
|
||||
entity.HasIndex(e => e.Iddivisa, "FK_propdiv");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id");
|
||||
@@ -425,6 +646,9 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Dnipropietario)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("dnipropietario");
|
||||
entity.Property(e => e.Iddivisa)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("iddivisa");
|
||||
entity.Property(e => e.Idestado)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("idestado");
|
||||
@@ -435,6 +659,9 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.HasMaxLength(1)
|
||||
.IsFixedLength()
|
||||
.HasColumnName("letra");
|
||||
entity.Property(e => e.Monto)
|
||||
.HasPrecision(10)
|
||||
.HasColumnName("monto");
|
||||
entity.Property(e => e.Piso)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("piso");
|
||||
@@ -447,6 +674,11 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_PROP_PROPI");
|
||||
|
||||
entity.HasOne(d => d.IddivisaNavigation).WithMany(p => p.Propiedades)
|
||||
.HasForeignKey(d => d.Iddivisa)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_propdiv");
|
||||
|
||||
entity.HasOne(d => d.IdestadoNavigation).WithMany(p => p.Propiedades)
|
||||
.HasForeignKey(d => d.Idestado)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
@@ -537,6 +769,8 @@ public partial class AlquilaFacilContext : DbContext
|
||||
|
||||
entity.HasIndex(e => e.Idpropiedad, "FK_VEN_PROP");
|
||||
|
||||
entity.HasIndex(e => e.Iddivisa, "FK_ventdiv");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("id");
|
||||
@@ -552,6 +786,9 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.IdVendedor)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("idVendedor");
|
||||
entity.Property(e => e.Iddivisa)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("iddivisa");
|
||||
entity.Property(e => e.Idestado)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("idestado");
|
||||
@@ -561,6 +798,9 @@ public partial class AlquilaFacilContext : DbContext
|
||||
entity.Property(e => e.Monto)
|
||||
.HasPrecision(12)
|
||||
.HasColumnName("monto");
|
||||
entity.Property(e => e.UrlRecibo)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("urlRecibo");
|
||||
|
||||
entity.HasOne(d => d.IdCompradorNavigation).WithMany(p => p.VentaIdCompradorNavigations)
|
||||
.HasForeignKey(d => d.IdComprador)
|
||||
@@ -572,6 +812,11 @@ public partial class AlquilaFacilContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_VEN_PROL");
|
||||
|
||||
entity.HasOne(d => d.IddivisaNavigation).WithMany(p => p.Venta)
|
||||
.HasForeignKey(d => d.Iddivisa)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.HasConstraintName("FK_ventdiv");
|
||||
|
||||
entity.HasOne(d => d.IdestadoNavigation).WithMany(p => p.Venta)
|
||||
.HasForeignKey(d => d.Idestado)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Entidades;
|
||||
@@ -23,10 +23,21 @@ public partial class Cliente
|
||||
|
||||
public ulong Habilitado { get; set; }
|
||||
|
||||
public string? EmailRecuperacion { get; set; }
|
||||
|
||||
public string? F2a { get; set; }
|
||||
|
||||
|
||||
public virtual ICollection<Contrato> ContratoDniinquilinoNavigations { get; set; } = new List<Contrato>();
|
||||
|
||||
public virtual ICollection<Contrato> ContratoDnipropietarioNavigations { get; set; } = new List<Contrato>();
|
||||
|
||||
public virtual ICollection<Log> Logs { get; set; } = new List<Log>();
|
||||
|
||||
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<Venta> VentaIdCompradorNavigations { get; set; } = new List<Venta>();
|
||||
|
||||
@@ -27,17 +27,29 @@ public partial class Contrato
|
||||
|
||||
public ulong Habilitado { get; set; }
|
||||
|
||||
public int MesesHastaAumento { get; set; }
|
||||
|
||||
public string? UrlContrato { get; set; }
|
||||
|
||||
public ulong Cancelado { get; set; }
|
||||
|
||||
public int Iddivisa { get; set; }
|
||||
|
||||
public int MesesDurationContrato { get; set; }
|
||||
|
||||
public virtual ICollection<Defecto> Defectos { get; set; } = new List<Defecto>();
|
||||
|
||||
public virtual Cliente? DniinquilinoNavigation { get; set; }
|
||||
|
||||
public virtual Cliente? DnipropietarioNavigation { get; set; }
|
||||
|
||||
public virtual Divisa IddivisaNavigation { get; set; } = null!;
|
||||
|
||||
public virtual Propiedade? IdpropiedadNavigation { 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<Garante> Idgarantes { get; set; } = new List<Garante>();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ public partial class Defecto
|
||||
|
||||
public ulong Pagainquilino { get; set; }
|
||||
|
||||
public int Iddivisa { get; set; }
|
||||
|
||||
public virtual Contrato? IdcontratoNavigation { get; set; }
|
||||
|
||||
public virtual Divisa IddivisaNavigation { get; set; } = null!;
|
||||
|
||||
public virtual Estadodefecto? IdestadoNavigation { get; set; }
|
||||
}
|
||||
|
||||
19
Entidades/Divisa.cs
Normal file
19
Entidades/Divisa.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Entidades;
|
||||
|
||||
public partial class Divisa
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Signo { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Contrato> Contratos { get; set; } = new List<Contrato>();
|
||||
|
||||
public virtual ICollection<Defecto> Defectos { get; set; } = new List<Defecto>();
|
||||
|
||||
public virtual ICollection<Propiedade> Propiedades { get; set; } = new List<Propiedade>();
|
||||
|
||||
public virtual ICollection<Venta> Venta { get; set; } = new List<Venta>();
|
||||
}
|
||||
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; }
|
||||
}
|
||||
8
Entidades/Dto/AltaDefectoDto.cs
Normal file
8
Entidades/Dto/AltaDefectoDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entidades.Dto;
|
||||
public class AltaDefectoDto {
|
||||
public string Descripcion { get; set; } ="";
|
||||
public Decimal Costo { get; set; }
|
||||
public ulong Pagainquilino { get; set; }
|
||||
public int Iddivisa { get; set; }
|
||||
public long Idcontrato { 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,6 @@ public class AltaPropiedadDto {
|
||||
public string? Letra { get; set; } = null;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public int Idtipropiedad { get; set; }
|
||||
public int Monto { get; set; }
|
||||
public int Iddivisa { get; set; }
|
||||
}
|
||||
5
Entidades/Dto/AvisoInquilinoDto.cs
Normal file
5
Entidades/Dto/AvisoInquilinoDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Entidades.Dto;
|
||||
public class AvisoInquilinoDto {
|
||||
public string Mensaje { get; set; } ="";
|
||||
public long Idpropiedad { 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;
|
||||
}
|
||||
10
Entidades/Dto/CanonDto.cs
Normal file
10
Entidades/Dto/CanonDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Entidades.Dto;
|
||||
public class CanonDto{
|
||||
public long Id { get; set;}
|
||||
public int MesNum { get; set;}
|
||||
public DateTime Mes { get; set;}
|
||||
public Decimal Monto { get; set;}
|
||||
public string Divisa { get; set;} = "";
|
||||
public bool Pago { get; set;}
|
||||
|
||||
}
|
||||
23
Entidades/Dto/Chart/Chartjs.cs
Normal file
23
Entidades/Dto/Chart/Chartjs.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class ChartData
|
||||
{
|
||||
[JsonPropertyName("labels")]
|
||||
public List<string> Labels { get; set; }=new();
|
||||
|
||||
[JsonPropertyName("datasets")]
|
||||
public List<Dataset> Datasets { get; set; }=new();
|
||||
}
|
||||
|
||||
public class Dataset
|
||||
{
|
||||
[JsonPropertyName("label")]
|
||||
public string Label { get; set; } ="";
|
||||
|
||||
[JsonPropertyName("data")]
|
||||
public List<string> Data { get; set; }= new();
|
||||
|
||||
[JsonPropertyName("borderWidth")]
|
||||
public int BorderWidth { get; set; }=1;
|
||||
}
|
||||
11
Entidades/Dto/ContratoDto.cs
Normal file
11
Entidades/Dto/ContratoDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Entidades.Dto;
|
||||
public class ContratoDto {
|
||||
public long id { get; set; }
|
||||
public string Ubicacion { get; set; }="";
|
||||
public string TipoPropiedad { get; set; }="";
|
||||
public DateTime Fechainicio { get; set; }
|
||||
public string Inquilino { get; set; }="";
|
||||
public string Propietario { get; set; }="";
|
||||
public string Estado {get; set;}="";
|
||||
|
||||
}
|
||||
8
Entidades/Dto/ContratoPropiedadDto.cs
Normal file
8
Entidades/Dto/ContratoPropiedadDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entidades.Dto;
|
||||
public class ContratoPropiedadDto : ContratoDto {
|
||||
public int Habitaciones { get; set; }
|
||||
public int Piso { get; set;}
|
||||
public string Letra { get; set; } = "";
|
||||
public int MesesAumento { get; set; }
|
||||
public int MesesDuracion { get; set; }
|
||||
}
|
||||
5
Entidades/Dto/CrearAccionesDto.cs
Normal file
5
Entidades/Dto/CrearAccionesDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Entidades.Dto;
|
||||
public class CrearAccionesDto
|
||||
{
|
||||
public string Descripcion { get; set; } = "";
|
||||
}
|
||||
6
Entidades/Dto/CrearCanonsDto.cs
Normal file
6
Entidades/Dto/CrearCanonsDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Entidades.Dto;
|
||||
|
||||
public class CrearCanonsDto {
|
||||
public long idcontrato{ get; set; }
|
||||
public decimal aumento{ get; set; }
|
||||
}
|
||||
10
Entidades/Dto/DefectoDto.cs
Normal file
10
Entidades/Dto/DefectoDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Entidades.Dto;
|
||||
public class DefectoDto {
|
||||
public long Id { get; set;}
|
||||
public string Descripcion { get; set;} ="";
|
||||
public Decimal Costo { get; set;}
|
||||
public string Estado { get; set;} ="";
|
||||
public long Idcontrato { get; set;}
|
||||
public string Pagainquilino { get; set;} ="";
|
||||
public string Divisa { get; set;} ="";
|
||||
}
|
||||
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!;
|
||||
|
||||
}
|
||||
16
Entidades/Dto/GrupoYPermisoDto.cs
Normal file
16
Entidades/Dto/GrupoYPermisoDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Entidades.Dto;
|
||||
public class GrupoDto
|
||||
{
|
||||
public int idgrupo { get; set; }
|
||||
public string Nombre { get; set; } = "";
|
||||
public bool Habilitado { get; set; } = false;
|
||||
public HashSet<string> GruposIncluidos { get; set; } = [];
|
||||
public List<PermisoDto> Permisos { get; set; } = [];
|
||||
|
||||
}
|
||||
|
||||
public class PermisoDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Descripcion { get; set; } = "";
|
||||
}
|
||||
6
Entidades/Dto/MarcarPagoDto.cs
Normal file
6
Entidades/Dto/MarcarPagoDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Entidades.Dto;
|
||||
public class MarcarPagoDto {
|
||||
public long Idcontrato { get; set; }
|
||||
public DateTime fecha { get; set; }
|
||||
|
||||
}
|
||||
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);
|
||||
8
Entidades/Dto/OpcionVentaDto.cs
Normal file
8
Entidades/Dto/OpcionVentaDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entidades.Dto;
|
||||
public class OpcionVentaDto{
|
||||
public long Id { get; set;}
|
||||
public decimal Monto { get; set;}
|
||||
public string Divisa { get; set;} ="";
|
||||
public bool EnOrden { get; set;}
|
||||
public bool FueEjercido { get; set; }
|
||||
}
|
||||
@@ -1,3 +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);
|
||||
public record PatchPropiedadDto(int id, string Ubicacion, int Canthabitaciones, int? Piso, string? Letra, string Email, int tipo, List<string> Servicios, int Monto, int Iddivisa);
|
||||
|
||||
7
Entidades/Dto/PreContratoDataDto.cs
Normal file
7
Entidades/Dto/PreContratoDataDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
public class PreContratoDataDto{
|
||||
public bool TieneOpcionDeVenta { get; set; }
|
||||
public decimal? MontoOpcionDeVenta { get; set; }
|
||||
public string? MonedaOpcionDeVenta { get; set; }
|
||||
public int DuracionEnMeses { get; set; }
|
||||
public int? FrecuenciaAumentoEnMeses { get; set; }
|
||||
}
|
||||
13
Entidades/Dto/PrecontratoDto.cs
Normal file
13
Entidades/Dto/PrecontratoDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
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; } = "";
|
||||
public int MesesDuracionContrato { get; set; }
|
||||
public Decimal MontoOpcion {get; set; }
|
||||
public int iddivisa { get; set; }
|
||||
}
|
||||
@@ -7,4 +7,6 @@ public class PropiedadesDto {
|
||||
public string letra { get; set; } = "";
|
||||
public string Tipo { get; set; } = "";
|
||||
public string? Servicios {get;set;} = "";
|
||||
public int Monto { get; set; }
|
||||
public int Iddivisa { get; set; }
|
||||
}
|
||||
|
||||
12
Entidades/Dto/PropiedadesVentaDto.cs
Normal file
12
Entidades/Dto/PropiedadesVentaDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Entidades.Dto;
|
||||
public class PropiedadesVentaDto {
|
||||
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 decimal Monto { get; set; }
|
||||
public string Divisa { get; set; }="";
|
||||
}
|
||||
6
Entidades/Dto/PropietarioDto.cs
Normal file
6
Entidades/Dto/PropietarioDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Entidades.Dto;
|
||||
public class PropietarioDto{
|
||||
public string Nombre {get; set;} = "";
|
||||
public long Dni {get; set;}
|
||||
public string Apellido {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/SetVentaDto.cs
Normal file
6
Entidades/Dto/SetVentaDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Entidades.Dto;
|
||||
public class SetVentaDto {
|
||||
public int idpropiedad {get; set;}
|
||||
public decimal monto {get; set;}
|
||||
public int iddivisa {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; }
|
||||
}
|
||||
12
Entidades/Dto/UsuarioDto.cs
Normal file
12
Entidades/Dto/UsuarioDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Entidades.Dto;
|
||||
|
||||
public class UsuarioDto
|
||||
{
|
||||
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 Email { get; set; } = null!;
|
||||
public string? EmailRecuperacion { get; set; } = null!;
|
||||
}
|
||||
12
Entidades/Dto/VentasDto.cs
Normal file
12
Entidades/Dto/VentasDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Entidades.Dto;
|
||||
public class VentasDto {
|
||||
public long Id { get; set; }
|
||||
public decimal Monto { get; set; }
|
||||
public string Divisa { get; set; }="";
|
||||
public string Ubicacion { get; set; }="";
|
||||
public string NombreVendedor { get; set; }="";
|
||||
public long IdVendedor { get; set; }
|
||||
public string NombreComprador { get; set; }="";
|
||||
public long IdComprador { get; set; }
|
||||
public string Estado { get; set; }="";
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user