Exemplo n.º 1
0
            public async Task <GestionRiesgoVM> Handle(GetGestionRiesgoQuery request, CancellationToken cancellationToken)
            {
                GestionRiesgoVM padre           = new GestionRiesgoVM();
                var             GestionRiesgoEj = _context.TGestionRiesgo.Include(i => i.Hijos);/*.AsQueryable().Distinct().OrderBy(x => x);*//*.Skip(0).Take(10);*/

                var GestionRiesgoPadre = new GestionRiesgoVM();

                GestionRiesgoPadre.count = 0;

                List <TUbicacion> ListJerarquia = new List <TUbicacion>();
                var cont = 0;

                foreach (var item in GestionRiesgoEj)
                {
                    cont = item.Hijos.Count;
                }

                foreach (var item in GestionRiesgoEj)
                {
                    if (item.CodGestionRiesgoPadre == null)
                    {
                        GestionRiesgoNodeVM node = recursion(item);
                        GestionRiesgoPadre.data.Add(node);
                        GestionRiesgoPadre.count++;
                    }
                }
                return(GestionRiesgoPadre);
            }
Exemplo n.º 2
0
            public GestionRiesgoNodeVM recursion(TGestionRiesgo it)
            {
                var ubicacionPadre = new GestionRiesgoNodeVM();

                ubicacionPadre.Codigo          = it.CodGestionRiesgo;
                ubicacionPadre.Descripcion     = it.Descripcion;
                ubicacionPadre.DetalleAsociado = it.DetalleAsociado;
                if (it.Hijos.Count == 0)
                {
                    return(ubicacionPadre);
                }


                if (it.Hijos.Count > 0)
                {
                    foreach (var hijos in it.Hijos)
                    {
                        ubicacionPadre.children.Add(recursion(hijos));
                    }
                }
                return(ubicacionPadre);
            }