falta nomás definir los niveles de acceso
This commit is contained in:
@@ -47,13 +47,54 @@ public class DefectoController: ControllerBase {
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[HttpPost("api/defecto")] // WIP tengo que hablar con mi madre
|
||||
[HttpPost("api/defecto")] // WIP no se que permisos se necesitan
|
||||
public IActionResult AltaDefecto([FromHeader(Name = "Auth")] string Auth, AltaDefectoDto data) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false){
|
||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
string r = ValidarDto(data);
|
||||
if (r != "") return BadRequest(new { message = r });
|
||||
|
||||
Defecto defecto = new Defecto{
|
||||
Costo = data.Costo,
|
||||
Descripcion = data.Descripcion,
|
||||
Idcontrato = data.Idcontrato,
|
||||
Iddivisa = data.Iddivisa,
|
||||
Pagainquilino = data.Pagainquilino,
|
||||
Idestado = 1,
|
||||
|
||||
};
|
||||
var b = RepositorioDefectos.Singleton.AltaDefecto(defecto);
|
||||
return b ?Ok(new { message = "Se cargo el Defecto en el sistema"}):BadRequest(new { message ="No se pudo cargar el defecto en el sistema"});
|
||||
}
|
||||
|
||||
[HttpPut("api/defecto/marcarpago")] // WIP Prerequisito tener altadefecto
|
||||
private string ValidarDto(AltaDefectoDto d){
|
||||
string ret ="";
|
||||
|
||||
if (d == null) return "Dto nulo";
|
||||
if (d.Iddivisa <0 || d.Iddivisa>1) ret +="No son divisas validas\n";
|
||||
if (d.Descripcion == "") ret+="La descripcion no puede estar vacia\n";
|
||||
if (d.Idcontrato<=0)ret += "No puede haber un id de contrato iguao o menor a 0\n";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[HttpPut("api/defecto/marcarpago")] //WIP no se que permisos se necesitan
|
||||
public IActionResult MarcarPago([FromHeader(Name = "Auth")] string Auth, long iddefecto = 0) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false){
|
||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ using Entidades;
|
||||
namespace Modelo;
|
||||
|
||||
public class RepositorioDefectos: RepositorioBase<RepositorioDefectos> {
|
||||
public bool AltaDefecto(Defecto defecto){
|
||||
var con = Context;
|
||||
defecto.Id = con.Defectos.Any()? con.Defectos.Count()+1 : 1;
|
||||
con.Defectos.Add(defecto);
|
||||
}
|
||||
|
||||
public IQueryable<Defecto> ObtenerDefectosPorIdContrato(long idcontrato){
|
||||
var con = Context;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user