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){