v9.8.2018.0605   由DataReader直接映射实体列表,以支持netstandard的MySql和SQLite,且提升性能
大石头 authored at 2018-06-05 00:45:23
935.00 B
X
@using NewLife.Model;
@using XCode.Membership;
@{
    var user = ViewBag.User as IUser ?? User.Identity as IUser;

    var fact = ObjectContainer.Current.Resolve<IMenuFactory>();

    var item = Model as IMenu;
    var childs = fact.GetMySubMenus(item.ID, user).Where(m => m.Visible);
    var url = item.Url.IsNullOrEmpty() ? "" : Url.Content(item.Url);
}
<li>
    @if (childs.Any())
    {
        <a href="#" class="dropdown-toggle">
            <i class="menu-icon fa fa-caret-right"></i>
            @item.DisplayName
        </a>
    }
    else
    {
        <a href="@url" target="main">
            <i class="menu-icon fa fa-caret-right"></i>
            @item.DisplayName
        </a>

        <b class="arrow"></b>
        <ul class="submenu">
            @foreach (var menu in childs)
            {
                @Html.Partial("_Left_Item", menu);
            }
        </ul>
    }
</li>