creado toggle habilitar grupo y correjido un par de bugs de
modalestatico
This commit is contained in:
@@ -9,6 +9,12 @@ public class GrupoDtoBuilder : Builder<GrupoDto>
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConHabilitado(bool habilitado)
|
||||
{
|
||||
data.Habilitado = habilitado;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConIdGrupo(int id)
|
||||
{
|
||||
data.idgrupo = id;
|
||||
|
||||
@@ -21,6 +21,7 @@ public class GruposController : ControllerBase
|
||||
.Select(g => new GrupoDtoBuilder()
|
||||
.ConNombre(g.Nombre)
|
||||
.ConIdGrupo(g.Id)
|
||||
.ConHabilitado(g.Habilitado ?? false)
|
||||
.ConGruposIncluidos(new HashSet<string>(g.IdGrupoHijos
|
||||
.Select(id => id.Nombre ?? "")))
|
||||
.ConPermisos(g.Idpermisos.Select(p => new PermisoDtoBuilder()
|
||||
@@ -64,4 +65,20 @@ public class GruposController : ControllerBase
|
||||
bool ret2 = RepositorioGrupos.Singleton.AddGrupo(grupo, cli);
|
||||
return ret2 ? Ok(new { message = "Se Añadio el grupo" }) : BadRequest(new { message = "Fallo al añadirse el grupo" });
|
||||
}
|
||||
|
||||
[HttpDelete("/api/grupo")]
|
||||
public IActionResult DeleteGrupo([FromHeader(Name = "Auth")] string Auth, [FromQuery] int id)
|
||||
{
|
||||
var ret = RepositorioPermisos.Singleton.CheckPermisos(Auth, 18);
|
||||
if (ret == false) return BadRequest(new { message = "No tiene permiso para Gestionar grupos" });
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new { message = "No hay un cliente por el token que enviaste" });
|
||||
|
||||
if (id <= 0) return BadRequest(new { message = "El ID del grupo debe ser mayor que cero" });
|
||||
var (ret2, estado) = RepositorioGrupos.Singleton.ToggleGrupo(id, cli);
|
||||
return ret2
|
||||
? Ok(new { message = (estado ? "Grupo habilitado exitosamente" : "Grupo deshabilitado exitosamente") })
|
||||
: BadRequest(new { message = "No se pudo cambiar el estado del grupo" });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user