este es el trabajo de hoy
This commit is contained in:
@@ -25,6 +25,39 @@ public class PropiedadesController: ControllerBase {
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("/api/propiedades/Venta")]
|
||||
public IActionResult ObtenerPropiedadesParaVenta([FromHeader(Name = "Auth")] string Auth, int pag = 0) {
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
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);
|
||||
}
|
||||
return Ok(l);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedad")]
|
||||
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
|
||||
@@ -14,6 +14,69 @@ namespace AlquilaFacil.Controllers;
|
||||
[ApiController]
|
||||
public class VentaController:ControllerBase {
|
||||
|
||||
[HttpGet("/api/propiedad/EstaALaVenta")]
|
||||
public IActionResult EstaALaVenta([FromHeader(Name="Auth")]string Auth, int idprop=0) {
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
if (idprop<=0) return BadRequest(new { message = "No hay propiedades con id 0 o menor"});
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(idprop);
|
||||
if (prop == null) return BadRequest(new { message = "No hay propiedades por ese id"});
|
||||
return Ok(new { EstaAVenta = prop.Idestado ==4?true:false});
|
||||
}
|
||||
|
||||
[HttpPut("/api/propiedad/setPropiedadAVenta")]
|
||||
public IActionResult setPropiedadAVenta([FromHeader(Name="Auth")]string Auth, SetVentaDto dto) {
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
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();
|
||||
|
||||
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 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
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 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
|
||||
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/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;}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
import VerLogs from "./paginas/VerLogs.svelte";
|
||||
import ControlPagos from "./paginas/ControlPagos.svelte";
|
||||
import ContratoAdmin from "./paginas/ContratoAdmin.svelte";
|
||||
import BuscarVentas from "./paginas/BuscarVentas.svelte";
|
||||
</script>
|
||||
|
||||
<Router>
|
||||
@@ -115,6 +116,10 @@
|
||||
<ProteRoute componente={ControlPagos}/>
|
||||
</Route>
|
||||
|
||||
<!-- Buscar Ventas -->
|
||||
<Route path="/accion/16">
|
||||
<ProteRoute componente={BuscarVentas}/>
|
||||
</Route>
|
||||
<!-- Pagina Ventas -->
|
||||
<Route path="/Ventas">
|
||||
<ProteRoute componente={Ventas}/>
|
||||
@@ -149,7 +154,7 @@
|
||||
<ProteRoute componente={ContratoInquilino}/>
|
||||
</Route>
|
||||
|
||||
<!--Contratos Inquilino-->
|
||||
<!--Contratos Admin-->
|
||||
<Route path="/admin/contratos">
|
||||
<ProteRoute componente={ContratoAdmin}/>
|
||||
</Route>
|
||||
|
||||
44
Front/src/Componentes/ModalPublicarPropiedadParaVenta.svelte
Normal file
44
Front/src/Componentes/ModalPublicarPropiedadParaVenta.svelte
Normal file
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
|
||||
let {onClose, onConfirm}: {onClose:()=>void, onConfirm:()=>void} = $props();
|
||||
let monto:number = $state(0);
|
||||
|
||||
|
||||
function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
onConfirm();onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Contrato</h5>
|
||||
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="monto"
|
||||
class="form-control"
|
||||
bind:value={monto}
|
||||
placeholder="0"
|
||||
required
|
||||
/>
|
||||
<label for="monto">Monto</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" onclick={(e)=> handleSubmit(e)}>Publicar a la venta</button>
|
||||
|
||||
<button class="btn btn-secondary ms-auto" onclick={onClose}>Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,12 +6,14 @@
|
||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja", monto, iddivisa = 0 } = $props();
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import ModalPublicarPropiedadParaVenta from "./ModalPublicarPropiedadParaVenta.svelte";
|
||||
|
||||
let modal: boolean = $state(false);
|
||||
let modalpayload: string = $state("");
|
||||
|
||||
let modificar: boolean = $state(false);
|
||||
|
||||
let showPublicarVenta: boolean = $state(false);
|
||||
|
||||
function setmod(){
|
||||
modificar = !modificar;
|
||||
}
|
||||
@@ -35,6 +37,13 @@
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function setventa() {
|
||||
showPublicarVenta = true;
|
||||
}
|
||||
async function sendMod() {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr in:fade>
|
||||
@@ -53,9 +62,10 @@
|
||||
{/if}
|
||||
</td>
|
||||
<td>{monto}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-outline-secondary btn-sm" onclick={()=> setmod()}>Modificar</button>
|
||||
<button class="btn btn-outline-danger btn-sm" onclick={() => BajaPropiedad()}>{btnbaja}</button>
|
||||
<td class="d-flex justify-content-between gap-2">
|
||||
<button class="btn btn-secondary btn-sm" onclick={()=> setmod()}>Modificar</button>
|
||||
<button class="btn btn-secondary btn-sm" onclick={()=> setventa()}>Publicar a venta</button>
|
||||
<button class="btn btn-danger btn-sm" onclick={() => BajaPropiedad()}>{btnbaja}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{#if modal}
|
||||
@@ -68,3 +78,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{#if showPublicarVenta}
|
||||
<ModalPublicarPropiedadParaVenta onClose={()=>!!(showPublicarVenta = false)} onConfirm={sendMod}/>
|
||||
{/if}
|
||||
14
Front/src/paginas/BuscarVentas.svelte
Normal file
14
Front/src/paginas/BuscarVentas.svelte
Normal file
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { text } from "@sveltejs/kit";
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
|
||||
<div class="container-fluid mt-2">
|
||||
<BarraHorizontalConTexto text="Venta Propiedades"/>
|
||||
|
||||
</div>
|
||||
6
Front/src/types.d.ts
vendored
6
Front/src/types.d.ts
vendored
@@ -187,4 +187,10 @@ export type UpdateCliente = {
|
||||
apellido:string,
|
||||
domicilio:string,
|
||||
celular:string,
|
||||
}
|
||||
|
||||
export type setVenta = {
|
||||
idpropiedad:number,
|
||||
monto:number,
|
||||
iddivisa:number,
|
||||
}
|
||||
@@ -611,4 +611,13 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
||||
|
||||
return (int)Math.Ceiling((double)totalRegistros / registrosPorPagina);
|
||||
}
|
||||
|
||||
public IQueryable<Propiedade>? ObtenerPropiedadesEnVenta(int pag){
|
||||
var con = Context;
|
||||
|
||||
var props = con.Propiedades.Include(x=>x.IdServicios).Include(x=>x.IddivisaNavigation)
|
||||
.Include(c=>c.IdtipropiedadNavigation)
|
||||
.Where(x=>x.Idestado ==4).Skip(pag*10).Take(10);
|
||||
return props;
|
||||
}
|
||||
}
|
||||
@@ -72,4 +72,33 @@ public class RepositorioVentas: RepositorioBase<RepositorioVentas> {
|
||||
GenerarLog(con, dni, $"Se seteo el recibo con nombre: {nuevoNombreArchivo}");
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool SetVenta(int idpropiedad, decimal monto, int iddivisa, long dni) {
|
||||
var con = Context;
|
||||
Propiedade? cont = con.Propiedades.Include(x=>x.Contratos).FirstOrDefault(x=>x.Id == idpropiedad);
|
||||
if (cont==null) return false;
|
||||
if (cont.Idestado == 2 || cont.Idestado == 4) return false;
|
||||
if (cont.Contratos.Any(x=>x.Habilitado == 1 && x.Cancelado == 0)) return false;
|
||||
|
||||
cont.Monto = monto;
|
||||
cont.Iddivisa = iddivisa;
|
||||
cont.Idestado = 4;
|
||||
GenerarLog(con, dni, "Se puso la propiedad de venta");
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool UnSetVenta(int id, decimal monto, int iddivisa, long dni) {
|
||||
var con = Context;
|
||||
Propiedade? cont = con.Propiedades.Include(x=>x.Venta).Include(x=>x.Contratos).FirstOrDefault(x=>x.Id == id);
|
||||
if (cont==null) return false;
|
||||
if (cont.Idestado != 4) return false;
|
||||
if (cont.Contratos.Any(x=>x.Habilitado == 1 && x.Cancelado == 0)) return false;
|
||||
if (cont.Venta.Any(x=>x.Idestado != 3)) return false;
|
||||
|
||||
cont.Monto = monto;
|
||||
cont.Iddivisa = iddivisa;
|
||||
cont.Idestado = 4;
|
||||
GenerarLog(con, dni, "Se Bajo la propiedad de venta");
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user