示例#1
0
 private void CargarSession()
 {
     IMenus bdd = new BusinessLogic();
     ROL rolSelected = Session["rolSelected"] as ROL;
     lblNombrePerfil.Text = "Rol seleccionado: " + rolSelected.DESCRIPCIONROL;
     List<MENU> menusInRol = bdd.GetMenusInRol(rolSelected.IDROL);
     List<MENU> menus = bdd.GetMenusConPadres();
     ListItemCollection collection = new ListItemCollection();
     ListItem item = null;
     menus.RemoveAt(0);
     menus.ForEach(menu =>
     {
         var menuFound = menusInRol.FirstOrDefault(x => x.IDMENU == menu.IDMENU);
         if (menuFound != null)
         {
             item = new ListItem
             {
                 Text = menuFound.DESCRIPCIONMENU,
                 Value = menuFound.IDMENU.ToString(),
                 Selected = true
             };
             collection.Add(item);
         }
         else
         {
             item = new ListItem
             {
                 Text = menu.DESCRIPCIONMENU,
                 Value = menu.IDMENU.ToString(),
                 Selected = false
             };
             collection.Add(item);
         }
     });
     chkMenus.Items.Clear();
     collection.ToList().ForEach(listItem => chkMenus.Items.Add(listItem));
 }