public Roles RolesDiponibles(int id) { Roles roles = new Roles(); RolesDAC rolesDAC = new RolesDAC(); roles = rolesDAC.ReadBy(id); PermisoDAC permisoDAC = new PermisoDAC(); List <Arbol> ListaPermiso = new List <Arbol>(); foreach (var item in rolesDAC.Read()) { ListaPermiso.Add(item); } foreach (var item in permisoDAC.Read()) { ListaPermiso.Add(item); } Roles rolesBase = new Roles(null, ListaPermiso); Roles result = new Roles(); result = rolesDAC.ReadBy(id); roles.ListaPermiso = ObtenerPermisosORolesDeUnRol(id); List <Arbol> listaroles = new List <Arbol>(); foreach (var item in rolesBase.ListaPermiso) { int a = 0; foreach (var subItem in roles.ListaPermiso) { if (subItem.Id == item.Id) { a = 1; } } if (result.Id == item.Id) { a = 1; } if (a == 0) { Arbol unRol = new Arbol(); unRol = item; listaroles.Add(unRol); } } result.ListaPermiso = listaroles; return(result); }
public Roles RolesDiponibles(int id) { Roles roles = new Roles(); RolesDAC rolesDAC = new RolesDAC(); roles = rolesDAC.ReadBy(id); Roles rolesBase = new Roles(); PermisoDAC permisoDAC = new PermisoDAC(); rolesBase.listaRol = rolesDAC.Read(); rolesBase.listaRol.AddRange(permisoDAC.Read()); Roles result = new Roles(); result = rolesDAC.ReadBy(id); roles.listaRol = ObtenerPermisosORolesDeUnRol(id); foreach (Roles item in rolesBase.listaRol) { int a = 0; foreach (Roles subItem in roles.listaRol) { if (subItem.Id == item.Id) { a = 1; } } if (result.Id == item.Id) { a = 1; } if (a == 0) { result.listaRol.Add(item); } } return(result); }
public List <Permiso> Read() { PermisoDAC permisoDAC = new PermisoDAC(); return(permisoDAC.Read()); }