avansando más
This commit is contained in:
44
Aspnet/Builder/DtoBuilder/GrupoyPermisoDtoBuilder.cs
Normal file
44
Aspnet/Builder/DtoBuilder/GrupoyPermisoDtoBuilder.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class GrupoDtoBuilder : Builder<GrupoDto>
|
||||
{
|
||||
public GrupoDtoBuilder ConNombre(string nombre)
|
||||
{
|
||||
data.Nombre = nombre;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConIdGrupo(int id)
|
||||
{
|
||||
data.idgrupo = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConGruposIncluidos(HashSet<string> grupos)
|
||||
{
|
||||
data.GruposIncluidos = grupos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GrupoDtoBuilder ConPermisos(List<PermisoDto> permisos)
|
||||
{
|
||||
data.Permisos = permisos;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class PermisoDtoBuilder : Builder<PermisoDto>
|
||||
{
|
||||
public PermisoDtoBuilder ConId(int id)
|
||||
{
|
||||
data.Id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermisoDtoBuilder ConDescripcion(string descripcion)
|
||||
{
|
||||
data.Descripcion = descripcion;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,36 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using AlquilaFacil.Builder;
|
||||
using Entidades;
|
||||
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class GruposController : ControllerBase
|
||||
{
|
||||
[HttpPost("api/admin/grupos")]
|
||||
[HttpGet("api/admin/grupos")]
|
||||
public IActionResult ObtenerGrupos([FromHeader(Name = "Auth")] string Auth)
|
||||
{//WIP
|
||||
{
|
||||
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" });
|
||||
|
||||
var grupos = RepositorioGrupos.Singleton.ListarTodosLosGrupos()
|
||||
.Select(g => new GrupoDtoBuilder()
|
||||
.ConNombre(g.Nombre)
|
||||
.ConIdGrupo(g.Id)
|
||||
.ConGruposIncluidos(new HashSet<string>(g.IdGrupoHijos
|
||||
.Select(id => id.ToString() ?? "")))
|
||||
.ConPermisos(g.Idpermisos.Select(p => new PermisoDtoBuilder()
|
||||
.ConId(p.Id)
|
||||
.ConDescripcion(p.Descripcion)
|
||||
.Build())
|
||||
.ToList())
|
||||
.Build())
|
||||
.ToList();
|
||||
|
||||
return Ok(grupos);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Modelo;
|
||||
using Entidades.Dto;
|
||||
namespace AlquilaFacil.Controllers;
|
||||
|
||||
[ApiController]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"usr":"nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt":"Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70"
|
||||
"usr": "nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
||||
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"usr":"nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt":"Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70"
|
||||
"usr": "nwFNMLJcn5m0owbzeXMs",
|
||||
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
||||
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user