feat: implementado todo lo de auditoria tocaria testearlo nomás
This commit is contained in:
@@ -117,8 +117,11 @@ public class AdminController: ControllerBase
|
||||
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);
|
||||
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"});
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ContratoController: ControllerBase {
|
||||
Fecha = c.Fecha,
|
||||
};
|
||||
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re);
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ContratoController: ControllerBase {
|
||||
Fecha = c.Fecha,
|
||||
};
|
||||
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re);
|
||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||
return ret ?
|
||||
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
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"});
|
||||
}
|
||||
@@ -352,14 +352,14 @@ public class ContratoController: ControllerBase {
|
||||
|
||||
bool ret;
|
||||
if (dto.TieneOpcionVenta==false){
|
||||
ret = RepositorioContratos.Singleton.CargaPrecontrato(precontrato, notificacion);
|
||||
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);
|
||||
ret = RepositorioContratos.Singleton.CargaPrecontratoOpcionVenta(precontrato, notificacion, v, cli.Dni);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
@@ -411,7 +411,7 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
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);
|
||||
@@ -440,6 +440,9 @@ public class ContratoController: ControllerBase {
|
||||
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"});
|
||||
@@ -451,10 +454,10 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
var ret = RepositorioContratos.Singleton.CancelarPrecontrato(dto.EmailInquilino, dto.idpropiedad, cli.Dni);
|
||||
if (ret) {
|
||||
prop.Idestado = 1;
|
||||
ret = RepositorioPropiedades.Singleton.PatchPropiedad(prop);
|
||||
ret = RepositorioPropiedades.Singleton.PatchPropiedad(prop, pro.Dni);
|
||||
if (ret){
|
||||
RepositorioNotificaciones.Singleton.MarcarComoLeido(pro.Dni, dto.fecha);
|
||||
var noti = new NotificacioneBuilder()
|
||||
@@ -549,7 +552,7 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
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()
|
||||
@@ -670,7 +673,7 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
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);
|
||||
@@ -707,7 +710,7 @@ public class ContratoController: ControllerBase {
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -53,6 +53,9 @@ public class DefectoController: ControllerBase {
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
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 });
|
||||
|
||||
@@ -65,7 +68,7 @@ public class DefectoController: ControllerBase {
|
||||
Idestado = 1,
|
||||
|
||||
};
|
||||
var b = RepositorioDefectos.Singleton.AltaDefecto(defecto);
|
||||
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"});
|
||||
}
|
||||
|
||||
@@ -86,8 +89,11 @@ public class DefectoController: ControllerBase {
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
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);
|
||||
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" });
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#if DEBUG
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
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);
|
||||
|
||||
if (String.IsNullOrEmpty(grupo.descripcion)) return BadRequest();
|
||||
|
||||
bool ret = RepositorioGrupos.Singleton.CrearGrupo(grupo.descripcion);
|
||||
return (ret) ? Ok(ret) : BadRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public record AdminGrupo(string descripcion);
|
||||
#endif
|
||||
@@ -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
|
||||
@@ -146,7 +146,7 @@ public class PropiedadesController: ControllerBase {
|
||||
Iddivisa = propiedad.Iddivisa,
|
||||
};
|
||||
|
||||
bool ret = RepositorioPropiedades.Singleton.PatchPropiedad(Prop);
|
||||
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"});
|
||||
@@ -203,11 +203,13 @@ public class PropiedadesController: ControllerBase {
|
||||
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"});
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VentaController:ControllerBase {
|
||||
venta.Idpropiedad = cont.Idpropiedad;
|
||||
venta.Fechainicio = DateTime.Now;
|
||||
|
||||
bool ret = RepositorioVentas.Singleton.PatchVenta(venta);
|
||||
bool ret = RepositorioVentas.Singleton.PatchVenta(venta, cli.Dni);
|
||||
|
||||
return ret?
|
||||
Ok(new { message = "Se ejercio la opcion de venta"}):
|
||||
@@ -72,7 +72,7 @@ public class VentaController:ControllerBase {
|
||||
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);
|
||||
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"});
|
||||
|
||||
Reference in New Issue
Block a user