Añadido soporte para crear grupos nuevos

This commit is contained in:
2025-04-21 16:01:15 -03:00
parent ffb860688d
commit 543bc9e5a6
6 changed files with 263 additions and 1 deletions

View File

@@ -6,6 +6,21 @@ using Microsoft.EntityFrameworkCore;
namespace Modelo;
public class RepositorioGrupos : RepositorioBase<RepositorioGrupos>
{
public bool AddGrupo(GrupoDto grupo, Cliente cli)
{
var con = Context;
var g = new Grupo
{
Id = con.Grupos.Max(x => x.Id) + 1,
Nombre = grupo.Nombre,
IdGrupoHijos = con.Grupos.Where(x => grupo.GruposIncluidos.Contains(x.Nombre)).ToList(),
Idpermisos = con.Permisos.Where(x => grupo.Permisos.Select(x => x.Id).Contains(x.Id)).ToList(),
};
con.Grupos.Add(g);
GenerarLog(con, cli.Dni, $"Alta Grupo: {g.Nombre}");
return Guardar(con);
}
public bool PatchGrupo(GrupoDto grupo, Cliente cli)
{
var con = Context;