feat: listar propiedades y baja propiedad
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using Entidades;
|
using Entidades;
|
||||||
using Entidades.Dto;
|
using Entidades.Dto;
|
||||||
using Microsoft.AspNetCore.Http.HttpResults;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Modelo;
|
using Modelo;
|
||||||
|
|
||||||
@@ -33,18 +32,17 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
[HttpGet("api/propiedades/Propietario")]
|
[HttpGet("api/propiedades/Propietario")]
|
||||||
public IActionResult ObtenerPropiedadesPorPropietario (
|
public IActionResult ObtenerPropiedadesPorPropietario (
|
||||||
[FromBody] string email,
|
[FromHeader(Name = "Email")] string email,
|
||||||
[FromHeader(Name = "Auth")] string Auth) {
|
[FromHeader(Name = "Auth")] string Auth) {
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
email = email.Trim();
|
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"});
|
||||||
|
|
||||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
IQueryable<PropiedadesDto> ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
||||||
|
|
||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,14 +74,16 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("api/propiedad")]
|
[HttpDelete("api/propiedad")]
|
||||||
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth){
|
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth, [FromHeader(Name = "Email")] string email){
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
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 (id <= 0) return BadRequest(new { message = "No es una id valida"});
|
||||||
|
|
||||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id);
|
Cliente? propie = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(email);
|
||||||
|
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id, propie);
|
||||||
|
|
||||||
return ret ?
|
return ret ?
|
||||||
Ok(new {message = $"la propiedad con id {id} fue dada de baja"}):
|
Ok(new {message = $"la propiedad con id {id} fue dada de baja"}):
|
||||||
@@ -147,4 +147,4 @@ public class PropiedadesController: ControllerBase {
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ public class PropiedadesDto {
|
|||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string Ubicacion { get; set; } = "";
|
public string Ubicacion { get; set; } = "";
|
||||||
public int canthabitaciones { get; set; }
|
public int canthabitaciones { get; set; }
|
||||||
public string piso { get; set; } = "";
|
public int piso { get; set; }
|
||||||
public string letra { get; set; } = "";
|
public string letra { get; set; } = "";
|
||||||
public string TipoPropiedad { get; set; } = "";
|
public string Tipo { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import InfoPage from './paginas/info.svelte';
|
import InfoPage from './paginas/info.svelte';
|
||||||
import InqPage from "./paginas/inquilino.svelte";
|
import InqPage from "./paginas/inquilino.svelte";
|
||||||
import PropPage from "./paginas/propietario.svelte";
|
import PropPage from "./paginas/propietario.svelte";
|
||||||
|
import MisPropiedades from "./paginas/MisPropiedades.svelte";
|
||||||
import FrontAdmin from "./paginas/grupos/AdminG.svelte";
|
import FrontAdmin from "./paginas/grupos/AdminG.svelte";
|
||||||
import FrontInformes from "./paginas/grupos/InformesG.svelte";
|
import FrontInformes from "./paginas/grupos/InformesG.svelte";
|
||||||
import FrontInquilino from "./paginas/grupos/InquilinoG.svelte";
|
import FrontInquilino from "./paginas/grupos/InquilinoG.svelte";
|
||||||
@@ -43,6 +44,12 @@
|
|||||||
<ProteRoute componente={PropPage}/>
|
<ProteRoute componente={PropPage}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!--Mis Propiedades-->
|
||||||
|
<Route path="/accion/2">
|
||||||
|
<ProteRoute componente={MisPropiedades}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
<!--Paginas info Grupo-->
|
||||||
<Route path="/grupo/Inquilino">
|
<Route path="/grupo/Inquilino">
|
||||||
<ProteRoute componente={FrontInquilino}/>
|
<ProteRoute componente={FrontInquilino}/>
|
||||||
</Route>
|
</Route>
|
||||||
@@ -56,5 +63,7 @@
|
|||||||
<ProteRoute componente={FrontInformes}/>
|
<ProteRoute componente={FrontInformes}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Router>
|
</Router>
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
import { Navbar, NavbarBrand, NavbarToggler, Nav, Collapse } from "@sveltestrap/sveltestrap";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import './css/popup.css';
|
import './css/popup.css';
|
||||||
|
import type { Grupo } from "../types";
|
||||||
let isOpen: boolean = $state(false);
|
let isOpen: boolean = $state(false);
|
||||||
|
|
||||||
type Permiso = {
|
|
||||||
id: number;
|
|
||||||
descripcion: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Grupo = {
|
|
||||||
id: number;
|
|
||||||
nombre: string;
|
|
||||||
idpermisos: Permiso[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const permisos = writable<Grupo[]>([]);
|
const permisos = writable<Grupo[]>([]);
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
const token = sessionStorage.getItem('token');
|
const token = sessionStorage.getItem('token');
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type {PropiedadDto} from "../types"
|
||||||
|
import ModalEstatico from "./ModalEstatico.svelte";
|
||||||
|
let { id, ubicacion, tipo, letra, piso }: PropiedadDto = $props();
|
||||||
|
|
||||||
|
let modal: boolean = $state(false)
|
||||||
|
let modalpayload: string = $state("")
|
||||||
|
|
||||||
|
async function BajaPropiedad(){
|
||||||
|
modal = false;
|
||||||
|
try {
|
||||||
|
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers:{
|
||||||
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
|
'Email' : String(localStorage.getItem("email"))
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responce.ok){
|
||||||
|
const json = await responce.json();
|
||||||
|
modalpayload = json.message;
|
||||||
|
modal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!responce.ok) {
|
||||||
|
const json = await responce.json();
|
||||||
|
modalpayload = json.message;
|
||||||
|
modal = true;
|
||||||
|
}
|
||||||
|
}catch (e){
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{id}</td>
|
||||||
|
<td>{ubicacion}</td>
|
||||||
|
<td>{letra}</td>
|
||||||
|
<td>{piso}</td>
|
||||||
|
<td>{tipo}</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<button class="btn btn-outline-secondary">Modificar</button>
|
||||||
|
<button class="btn btn-outline-danger" onclick={()=> BajaPropiedad()}>Baja</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{#if modal}
|
||||||
|
<ModalEstatico payload={modalpayload}/>
|
||||||
|
{/if}
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
let email = $state("")
|
let email = $state("")
|
||||||
let contraseña = $state("")
|
let contraseña = $state("")
|
||||||
let errorMessage = $state("")
|
let errorMessage = $state("")
|
||||||
let showAlert = false;
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
async function submitForm(event) {
|
async function submitForm(event) {
|
||||||
@@ -25,7 +24,6 @@
|
|||||||
if (!response.ok){
|
if (!response.ok){
|
||||||
const errorData = await response.json()
|
const errorData = await response.json()
|
||||||
errorMessage = errorData.message;
|
errorMessage = errorData.message;
|
||||||
showAlert = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte" ;
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||||
|
import type { PropiedadDto } from "../types";
|
||||||
|
|
||||||
|
let propiedades = writable<PropiedadDto[]>([]);
|
||||||
|
let email = localStorage.getItem("email");
|
||||||
|
let token = sessionStorage.getItem("token");
|
||||||
|
|
||||||
|
let fallo: boolean = $state(false);
|
||||||
|
|
||||||
|
onMount(async ()=> {
|
||||||
|
try {
|
||||||
|
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
'Auth': String(token),
|
||||||
|
'Email' : String(email),
|
||||||
|
'Content-Type' : "application/json"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (responce.ok){
|
||||||
|
const json = await responce.json();
|
||||||
|
propiedades.set(json);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!responce.ok){
|
||||||
|
fallo = true;
|
||||||
|
}
|
||||||
|
} catch (e){
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
<div class="container table-responsive">
|
||||||
|
<table class="table-responsive table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>ubicacion</th>
|
||||||
|
<th>Letra</th>
|
||||||
|
<th>Piso</th>
|
||||||
|
<th>Tipo</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each $propiedades as propiedad}
|
||||||
|
{@debug propiedad}
|
||||||
|
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo}/>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{#if fallo}
|
||||||
|
<div class="container alert alert-danger">Fallo al intentar Obtener la lista de propiedades</div>
|
||||||
|
{/if}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { writable } from "svelte/store"; // Importar writable para los estados
|
import { writable } from "svelte/store"; // Importar writable para los estados
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
|
||||||
type Propiedad = {
|
type Propiedad = {
|
||||||
ubicacion: string,
|
ubicacion: string,
|
||||||
@@ -51,73 +52,85 @@
|
|||||||
<NavBarAutocompletable />
|
<NavBarAutocompletable />
|
||||||
|
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container-fluid mt-4 row">
|
||||||
<h2>Registrar Propiedad</h2>
|
|
||||||
<form class="card card-body" onsubmit={submitForm}>
|
<div class="col-sm">
|
||||||
<div class="form-floating mb-3">
|
<BarraHorizontalConTexto text={"Formulario Alta propiedad"}/>
|
||||||
<input
|
Este es un formulario con el objetivo de que usted pueda registrar las propiedades <b>suyas</b> que quiera hacer visibles a las busquedas de inquilinos.
|
||||||
type="text"
|
<br><br>
|
||||||
id="ubicacion"
|
|
||||||
class="form-control"
|
<BarraHorizontalConTexto text={"Indicaciones"}/>
|
||||||
bind:value={propiedad.ubicacion}
|
Para poder cargar la propiedad deberá especificar su ubicacion, la cantidad de habitaciones que posée, en caso de ser un edificio el piso, y letra, y que tipo de propiedad és (casa, departamento, oficina...).
|
||||||
placeholder="Ubicación"
|
</div>
|
||||||
required
|
|
||||||
/>
|
<div class="col">
|
||||||
<label for="ubicacion">Ubicación</label>
|
<h2>Registrar Propiedad</h2>
|
||||||
</div>
|
<form class="card card-body" onsubmit={submitForm}>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
id="canthabitaciones"
|
id="ubicacion"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
bind:value={propiedad.canthabitaciones}
|
bind:value={propiedad.ubicacion}
|
||||||
min="1"
|
placeholder="Ubicación"
|
||||||
placeholder="Cantidad de Habitaciones"
|
required
|
||||||
required
|
/>
|
||||||
/>
|
<label for="ubicacion">Ubicación</label>
|
||||||
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
</div>
|
||||||
</div>
|
<div class="form-floating mb-3">
|
||||||
<div class="form-floating mb-3">
|
<input
|
||||||
<input
|
type="number"
|
||||||
type="number"
|
id="canthabitaciones"
|
||||||
id="piso"
|
class="form-control"
|
||||||
class="form-control"
|
bind:value={propiedad.canthabitaciones}
|
||||||
bind:value={propiedad.piso}
|
min="1"
|
||||||
min="0"
|
placeholder="Cantidad de Habitaciones"
|
||||||
placeholder="Piso"
|
required
|
||||||
/>
|
/>
|
||||||
<label for="piso">Piso</label>
|
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="number"
|
||||||
id="letra"
|
id="piso"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
bind:value={propiedad.letra}
|
bind:value={propiedad.piso}
|
||||||
maxlength="1"
|
min="0"
|
||||||
placeholder="Letra"
|
placeholder="Piso"
|
||||||
/>
|
/>
|
||||||
<label for="letra">Letra</label>
|
<label for="piso">Piso</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<select
|
<input
|
||||||
id="idtipropiedad"
|
type="text"
|
||||||
class="form-select"
|
id="letra"
|
||||||
bind:value={propiedad.idtipropiedad}
|
class="form-control"
|
||||||
required
|
bind:value={propiedad.letra}
|
||||||
>
|
maxlength="1"
|
||||||
<option value="1">Casa</option>
|
placeholder="Letra"
|
||||||
<option value="2">Piso</option>
|
/>
|
||||||
<option value="3">Departamento</option>
|
<label for="letra">Letra</label>
|
||||||
<option value="4">Galpon</option>
|
</div>
|
||||||
<option value="5">LocalComercial</option>
|
<div class="form-floating mb-3">
|
||||||
<option value="6">Oficina</option>
|
<select
|
||||||
</select>
|
id="idtipropiedad"
|
||||||
<label for="idtipropiedad">Tipo de Propiedad</label>
|
class="form-select"
|
||||||
</div>
|
bind:value={propiedad.idtipropiedad}
|
||||||
<button type="submit" class="btn btn-primary">Enviar</button>
|
required
|
||||||
</form>
|
>
|
||||||
|
<option value="1">Casa</option>
|
||||||
|
<option value="2">Piso</option>
|
||||||
|
<option value="3">Departamento</option>
|
||||||
|
<option value="4">Galpon</option>
|
||||||
|
<option value="5">LocalComercial</option>
|
||||||
|
<option value="6">Oficina</option>
|
||||||
|
</select>
|
||||||
|
<label for="idtipropiedad">Tipo de Propiedad</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Enviar</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if mostrarModal == true}
|
{#if mostrarModal == true}
|
||||||
<ModalEstatico payload={datosModal} />
|
<ModalEstatico payload={datosModal} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container-fluid">
|
||||||
<div class="row align-items-start">
|
<div class="row align-items-start">
|
||||||
<div class="col">
|
<div class="col-sm">
|
||||||
<br><br>
|
<br><br>
|
||||||
<TextBar text="Formulario Alta Inquilino" />
|
<TextBar text="Formulario Alta Inquilino" />
|
||||||
Este es un formulario para crear una cuenta de Propietario.
|
Este es un formulario para crear una cuenta de Propietario.
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container-fluid">
|
||||||
<div class="row align-items-start">
|
<div class="row align-items-start">
|
||||||
<div class="col">
|
<div class="col-sm">
|
||||||
<br><br>
|
<br><br>
|
||||||
<TextBar text="Formulario Alta Propietario" />
|
<TextBar text="Formulario Alta Propietario" />
|
||||||
Este es un formulario para crear una cuenta de Inquilino.
|
Este es un formulario para crear una cuenta de Inquilino.
|
||||||
|
|||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
export type PropiedadDto = {
|
||||||
|
id: number,
|
||||||
|
ubicacion: string,
|
||||||
|
tipo: string,
|
||||||
|
piso: string | null,
|
||||||
|
letra: string | null,
|
||||||
|
}
|
||||||
|
export type Permiso = {
|
||||||
|
id: number;
|
||||||
|
descripcion: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Grupo = {
|
||||||
|
id: number;
|
||||||
|
nombre: string;
|
||||||
|
idpermisos: Permiso[];
|
||||||
|
};
|
||||||
@@ -7,8 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Modelo;
|
using Modelo;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades>
|
public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
||||||
{
|
|
||||||
|
|
||||||
public IQueryable<PropiedadesDto> ListarPropiedades(){
|
public IQueryable<PropiedadesDto> ListarPropiedades(){
|
||||||
FormattableString sqlq = $"""
|
FormattableString sqlq = $"""
|
||||||
@@ -69,10 +68,10 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
|
|
||||||
public IQueryable<PropiedadesDto> ObtenerPropiedadesPorEmail(string email) {
|
public IQueryable<PropiedadesDto> ObtenerPropiedadesPorEmail(string email) {
|
||||||
FormattableString sqlq = $"""
|
FormattableString sqlq = $"""
|
||||||
SELECT p.id, p.ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as TipoPropiedad From Propiedades p
|
SELECT p.id, p.ubicacion as Ubicacion, p.canthabitaciones, p.piso, p.letra, tp.descripcion as Tipo From Propiedades p
|
||||||
JOIN Clientes c ON c.dni = p.dnipropietario
|
JOIN Clientes c ON c.dni = p.dnipropietario
|
||||||
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
JOIN TipoPropiedad tp ON tp.id = p.idtipropiedad
|
||||||
WHERE c.email = {email}
|
WHERE c.email = {email} AND p.idestado = 1
|
||||||
""";
|
""";
|
||||||
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
var ret = Context.Database.SqlQuery<PropiedadesDto>(sqlq);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -93,10 +92,14 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool BajaPropiedad(int id) {
|
public bool BajaPropiedad(int id, Cliente? cli) {
|
||||||
|
if (cli == null) return false;
|
||||||
|
|
||||||
var con = Context;
|
var con = Context;
|
||||||
Propiedade? prop = con.Propiedades.Find(id);
|
Propiedade? prop = con.Propiedades.FirstOrDefault(x=>x.Id == id);
|
||||||
if (prop == null) return false;
|
if (prop == null) return false;
|
||||||
|
Console.WriteLine("prop.dni: "+prop.Dnipropietario+", cli.dni: "+cli.Dni);
|
||||||
|
if (prop.Dnipropietario != cli.Dni) return false;
|
||||||
prop.Idestado = 3;
|
prop.Idestado = 3;
|
||||||
|
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
@@ -121,4 +124,4 @@ public bool AñadirPropiedad(Propiedade? prop) {
|
|||||||
|
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user