public static void LoadCapabilities(Cache cache)
    {
        var capabilities = new ENTCapabilityBOList();

        capabilities.Load();
        cache.Remove(CACHE_KEY_CAPABILITIES);
        cache[CACHE_KEY_CAPABILITIES] = capabilities;
    }
Пример #2
0
    private void AddCapabilitiesForMenuItems(ENTMenuItemBOList menuItems, ENTCapabilityBOList capabilities, string indentation)
    {
        //Loop around each menu item and create a row for each menu item and capability associated with the menu item
        foreach (var menuItem in menuItems)
        {
            //Get any capabilities with this item
            var capabilitiesForMenuItem = capabilities.GetByMenuItemId(menuItem.ID);

            if (!capabilitiesForMenuItem.Any())
            {
                //Just add the menu item to the row
                var tr = new TableRow();
                var tc = new TableCell();
                var lc = new LiteralControl();
                lc.Text     = indentation + menuItem.MenuItemName;
                tc.CssClass = "capabilityHeader";
                tc.Controls.Add(lc);
                tc.ColumnSpan = 3;
                tr.Cells.Add(tc);
                tblCapabilities.Rows.Add(tr);
            }
            else
            {
                //If there is only one capability associated with this menu item then just display the
                //menu item name and the radio buttons
                if (capabilitiesForMenuItem.Count() == 1)
                {
                    AddCapabilityToTable(capabilitiesForMenuItem.ElementAt(0), indentation + menuItem.MenuItemName);
                }
                else
                {
                    //Add a row for each capability
                    foreach (ENTCapabilityBO capability in capabilitiesForMenuItem)
                    {
                        AddCapabilityToTable(capability, indentation + menuItem.MenuItemName + " (" + capability.CapabilityName + ")");
                    }
                }
            }
            if (menuItem.ChildMenuItems.Count > 0)
            {
                AddCapabilitiesForMenuItems(menuItem.ChildMenuItems, capabilities, indentation + "---");
            }
        }
    }