From 9c12cfb26152c128cf709be63ed750cfad22ede1 Mon Sep 17 00:00:00 2001 From: fede Date: Tue, 21 Jan 2025 02:01:44 -0300 Subject: [PATCH] =?UTF-8?q?falta=20nom=C3=A1s=20definir=20los=20niveles=20?= =?UTF-8?q?de=20acceso.=20amende=20un=20parche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aspnet/Controllers/DefectoController.cs | 7 +++++-- Modelo/RepositorioDefectos.cs | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Aspnet/Controllers/DefectoController.cs b/Aspnet/Controllers/DefectoController.cs index 9a7a7e5..79c5829 100644 --- a/Aspnet/Controllers/DefectoController.cs +++ b/Aspnet/Controllers/DefectoController.cs @@ -94,7 +94,10 @@ public class DefectoController: ControllerBase { return Unauthorized(); } } - - + if (iddefecto<=0) return BadRequest(new { message = "No hay canones con id 0 o menor"}); + bool ret = RepositorioDefectos.Singleton.MarcarPago(iddefecto); + + 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" }); } } diff --git a/Modelo/RepositorioDefectos.cs b/Modelo/RepositorioDefectos.cs index 561e9b6..aebfb89 100644 --- a/Modelo/RepositorioDefectos.cs +++ b/Modelo/RepositorioDefectos.cs @@ -7,6 +7,15 @@ public class RepositorioDefectos: RepositorioBase { var con = Context; defecto.Id = con.Defectos.Any()? con.Defectos.Count()+1 : 1; con.Defectos.Add(defecto); + return Guardar(con); + } + + public bool MarcarPago(long iddefecto){ + var con = Context; + var d = con.Defectos.FirstOrDefault(x=>x.Id == iddefecto); + if (d == null)return false; + d.Idestado = 2; + return Guardar(con); } public IQueryable ObtenerDefectosPorIdContrato(long idcontrato){