feat: hecha la parte de gestion de propiedades en venta
This commit is contained in:
@@ -58,6 +58,36 @@ public class PropiedadesController: ControllerBase {
|
|||||||
return Ok(l);
|
return Ok(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/propiedades/Venta/Propietario")]
|
||||||
|
public IActionResult ObtenerPropiedadesVentaDePropietario( [FromHeader(Name = "Auth")] string Auth){
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
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")]
|
[HttpGet("api/propiedad")]
|
||||||
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
import ControlPagos from "./paginas/ControlPagos.svelte";
|
import ControlPagos from "./paginas/ControlPagos.svelte";
|
||||||
import ContratoAdmin from "./paginas/ContratoAdmin.svelte";
|
import ContratoAdmin from "./paginas/ContratoAdmin.svelte";
|
||||||
import BuscarVentas from "./paginas/BuscarVentas.svelte";
|
import BuscarVentas from "./paginas/BuscarVentas.svelte";
|
||||||
|
import MisPropiedadesEnVenta from "./paginas/MisPropiedadesEnVenta.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Router>
|
<Router>
|
||||||
@@ -116,10 +117,16 @@
|
|||||||
<ProteRoute componente={ControlPagos}/>
|
<ProteRoute componente={ControlPagos}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!-- VerPropiedadesEnVenta -->
|
||||||
|
<Route path="/accion/15">
|
||||||
|
<ProteRoute componente={MisPropiedadesEnVenta}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
<!-- Buscar Ventas -->
|
<!-- Buscar Ventas -->
|
||||||
<Route path="/accion/16">
|
<Route path="/accion/16">
|
||||||
<ProteRoute componente={BuscarVentas}/>
|
<ProteRoute componente={BuscarVentas}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<!-- Pagina Ventas -->
|
<!-- Pagina Ventas -->
|
||||||
<Route path="/Ventas">
|
<Route path="/Ventas">
|
||||||
<ProteRoute componente={Ventas}/>
|
<ProteRoute componente={Ventas}/>
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { PatchPropiedad, setVenta } from "../types";
|
||||||
|
|
||||||
let {onClose, onConfirm}: {onClose:()=>void, onConfirm:()=>void} = $props();
|
let {onClose, onConfirm, title = "Publicar para venta", btntext = "Publicar a la venta"
|
||||||
|
} : {
|
||||||
|
onClose:()=>void, onConfirm:(data:setVenta)=>void, title:string, btntext:string
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let data:setVenta = $state({iddivisa:0, idpropiedad:0, monto:0});
|
||||||
let monto:number = $state(0);
|
let monto:number = $state(0);
|
||||||
|
|
||||||
|
|
||||||
function handleSubmit(e: Event) {
|
function handleSubmit(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onConfirm();onClose();
|
onConfirm(data);onClose();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -14,7 +19,7 @@
|
|||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Contrato</h5>
|
<h5 class="modal-title">{title}</h5>
|
||||||
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -25,17 +30,23 @@
|
|||||||
type="number"
|
type="number"
|
||||||
id="monto"
|
id="monto"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
bind:value={monto}
|
bind:value={data.monto}
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<label for="monto">Monto</label>
|
<label for="monto">Monto</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<label for="divisa">divisa</label>
|
||||||
|
<select id="divisa" class="form-select">
|
||||||
|
<option value="0" selected>AR$</option>
|
||||||
|
<option value="1">US$</option>
|
||||||
|
</select>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-primary" onclick={(e)=> handleSubmit(e)}>Publicar a la venta</button>
|
<button class="btn btn-primary" onclick={(e)=> handleSubmit(e)}>{btntext}</button>
|
||||||
|
|
||||||
<button class="btn btn-secondary ms-auto" onclick={onClose}>Cerrar</button>
|
<button class="btn btn-secondary ms-auto" onclick={onClose}>Cerrar</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
||||||
|
|
||||||
let isOpen:boolean = false;
|
let isOpen:boolean =$state(false);
|
||||||
let theme = $state(localStorage.getItem("theme") ?? "light");
|
let theme = $state(localStorage.getItem("theme") ?? "light");
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
theme = theme === "light" ? "dark" : "light";
|
theme = theme === "light" ? "dark" : "light";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import { urlG } from "../stores/urlStore";
|
import { urlG } from "../stores/urlStore";
|
||||||
import ModalPublicarPropiedadParaVenta from "./ModalPublicarPropiedadParaVenta.svelte";
|
import ModalPublicarPropiedadParaVenta from "./ModalPublicarPropiedadParaVenta.svelte";
|
||||||
|
import type { setVenta } from "../types";
|
||||||
|
|
||||||
let modal: boolean = $state(false);
|
let modal: boolean = $state(false);
|
||||||
let modalpayload: string = $state("");
|
let modalpayload: string = $state("");
|
||||||
@@ -41,8 +42,27 @@
|
|||||||
function setventa() {
|
function setventa() {
|
||||||
showPublicarVenta = true;
|
showPublicarVenta = true;
|
||||||
}
|
}
|
||||||
async function sendMod() {
|
async function sendMod(data:setVenta) {
|
||||||
|
data.idpropiedad = id;
|
||||||
|
try {
|
||||||
|
const responce = await fetch(String($urlG)+"/api/propiedad/setPropiedadAVenta", {
|
||||||
|
method: "PUT",
|
||||||
|
headers:{
|
||||||
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
|
'Content-Type': "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
});
|
||||||
|
if(responce.ok){
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await responce.json();
|
||||||
|
modalpayload = json.message;
|
||||||
|
modal = true;
|
||||||
|
}catch (e){
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import type { PropiedadDto, setVenta } from "../types";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import ModalPublicarPropiedadParaVenta from "../Componentes/ModalPublicarPropiedadParaVenta.svelte";
|
||||||
|
import ModificarPropiedadForm from "../Componentes/modificarPropiedadForm.svelte";
|
||||||
|
|
||||||
|
let token = sessionStorage.getItem("token")||"";
|
||||||
|
|
||||||
|
let modaldata:string =$state("");
|
||||||
|
let propiedades:PropiedadDto[]|null = $state(null);
|
||||||
|
let modificar:boolean = $state(false);
|
||||||
|
let selprop:PropiedadDto = $state({canthabitaciones:0, id:0, iddivisa:0, letra:"", monto:0, piso:"", servicios:"", tipo:"", ubicacion:""});
|
||||||
|
|
||||||
|
onMount(()=>{
|
||||||
|
obtenerpropiedadesenventa();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function obtenerpropiedadesenventa() {
|
||||||
|
try{
|
||||||
|
const r = await fetch($urlG+"/api/propiedades/Venta/Propietario", {
|
||||||
|
method:"GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": token,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (r.ok) {
|
||||||
|
let data = await r.json();
|
||||||
|
propiedades =data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
modaldata= "Fallo la request"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setmod(p:PropiedadDto) {
|
||||||
|
if (modificar == false) selprop = p;
|
||||||
|
modificar =! modificar;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let showBajaVenta:boolean = $state(false);
|
||||||
|
|
||||||
|
function unsetventa(p:PropiedadDto) {
|
||||||
|
selprop = p;
|
||||||
|
showBajaVenta= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function submitBajaVenta(data:setVenta) {
|
||||||
|
data.idpropiedad = selprop.id;
|
||||||
|
try {
|
||||||
|
const responce = await fetch(String($urlG)+"/api/propiedad/unsetPropiedadAVenta", {
|
||||||
|
method: "PUT",
|
||||||
|
headers:{
|
||||||
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
|
'Content-Type': "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
});
|
||||||
|
if(responce.ok){
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await responce.json();
|
||||||
|
modaldata = json.message;
|
||||||
|
}catch (e){
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BajaPropiedad(): any {
|
||||||
|
throw new Error("Function not implemented.");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if showBajaVenta}
|
||||||
|
<ModalPublicarPropiedadParaVenta btntext="Bajar de Venta" title="Bajar de venta" onClose={()=>!!(showBajaVenta=false)} onConfirm={submitBajaVenta}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container-fluid table-responsive mt-2">
|
||||||
|
<BarraHorizontalConTexto text="Propiedades En Venta"/>
|
||||||
|
<table class="container-fluid table-responsive table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>ubicacion</th>
|
||||||
|
<th>Habitaciones</th>
|
||||||
|
<th>Letra</th>
|
||||||
|
<th>Piso</th>
|
||||||
|
<th>Tipo</th>
|
||||||
|
<th>Servicios</th>
|
||||||
|
<th>Divisa</th>
|
||||||
|
<th>Monto</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{#if propiedades == null}
|
||||||
|
<tr>
|
||||||
|
<td colspan="10">
|
||||||
|
<div class="spinner-border" role="status"></div>
|
||||||
|
<span>Cargando...</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{:else if propiedades.length <=0}
|
||||||
|
<tr>
|
||||||
|
<td colspan="10">No hay propiedades en venta para este usuario</td>
|
||||||
|
</tr>
|
||||||
|
{:else}
|
||||||
|
{#each propiedades as p}
|
||||||
|
<tr in:fade>
|
||||||
|
<td>{p.id}</td>
|
||||||
|
<td>{p.ubicacion}</td>
|
||||||
|
<td>{p.canthabitaciones}</td>
|
||||||
|
<td>{p.letra}</td>
|
||||||
|
<td>{p.piso}</td>
|
||||||
|
<td>{p.tipo}</td>
|
||||||
|
<td>{p.servicios}</td>
|
||||||
|
<td>
|
||||||
|
{#if p.iddivisa == 0}
|
||||||
|
AR$
|
||||||
|
{:else}
|
||||||
|
US$
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
<td>{p.monto}</td>
|
||||||
|
<td class="d-flex justify-content-between gap-2">
|
||||||
|
<button class="btn btn-secondary btn-sm" onclick={()=> setmod(p)}>Modificar</button>
|
||||||
|
<button class="btn btn-secondary btn-sm" onclick={()=> unsetventa(p)}>Bajar de venta</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{#if modificar}
|
||||||
|
<tr transition:fade={{duration:100}}>
|
||||||
|
<td colspan="10">
|
||||||
|
<ModificarPropiedadForm id={selprop.id} ubicacion={selprop.ubicacion}
|
||||||
|
canthabitaciones={selprop.canthabitaciones} letra={selprop.letra} piso={selprop.piso}
|
||||||
|
tipo={selprop.tipo} servicios={selprop.servicios} monto={selprop.monto} iddivisa={selprop.iddivisa}/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
Vendored
+13
@@ -194,3 +194,16 @@ export type setVenta = {
|
|||||||
monto:number,
|
monto:number,
|
||||||
iddivisa:number,
|
iddivisa:number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PatchPropiedad = {
|
||||||
|
id:number,
|
||||||
|
ubicacion:string,
|
||||||
|
canthabitaciones:number,
|
||||||
|
piso:number,
|
||||||
|
letra:string,
|
||||||
|
email:string,
|
||||||
|
tipo:number,
|
||||||
|
servicios: string[],
|
||||||
|
monto:number,
|
||||||
|
iddivisa:number
|
||||||
|
}
|
||||||
@@ -620,4 +620,11 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
|||||||
.Where(x=>x.Idestado ==4).Skip(pag*10).Take(10);
|
.Where(x=>x.Idestado ==4).Skip(pag*10).Take(10);
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IQueryable<Propiedade> ObtenerPropiedadesAVentaPorDni(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
var l = con.Propiedades.Include(x=>x.IdServicios).Include(x=>x.IdtipropiedadNavigation)
|
||||||
|
.Where(x=>x.Dnipropietario == dni && x.Idestado ==4);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class RepositorioVentas: RepositorioBase<RepositorioVentas> {
|
|||||||
|
|
||||||
cont.Monto = monto;
|
cont.Monto = monto;
|
||||||
cont.Iddivisa = iddivisa;
|
cont.Iddivisa = iddivisa;
|
||||||
cont.Idestado = 4;
|
cont.Idestado = 3;
|
||||||
GenerarLog(con, dni, "Se Bajo la propiedad de venta");
|
GenerarLog(con, dni, "Se Bajo la propiedad de venta");
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user