Example #1
0
        //public List<VM.Common.SiteMenu> GetFrontDynamicSiteMenu(VM.UserModel user)
        //{
        //    List<VM.Common.SiteMenu> frontMenus = new List<VM.Common.SiteMenu>();
        //    if (user != null && user.RoleList != null)
        //    {
        //        if (user.RoleList.Contains((int)RoleID.SystemAdmin))
        //        {
        //            frontMenus.Add(new VM.Common.SiteMenu() { ResourceKey = CommonResource.Menu_Front_SysManagement, Area = "BackEndHome", Controller = "TIHome", ActionName = "Index" });
        //        }
        //        if (user.RoleList.Contains((int)RoleID.TCAdmin))
        //        {
        //            frontMenus.Add(new VM.Common.SiteMenu() { ResourceKey = CommonResource.Menu_Front_TCManagement, Area = "BackEndHome", Controller = "TIHome", ActionName = "Index" });
        //        }
        //    }
        //    return frontMenus;
        //}

        private List <VM.Common.SiteMenu> GetChildMenu(VM.Common.SiteMenu parentMenu, List <MD.Common_SiteMap_Menu> siteMenus)
        {
            List <VM.Common.SiteMenu> vwSiteMenus = null;

            if (siteMenus != null && siteMenus.Count > 0)
            {
                vwSiteMenus = ConvertToVMMenu(siteMenus.Where(p => p.ParentID.HasValue && p.ParentID.Value == parentMenu.MenuID), parentMenu);
                vwSiteMenus.ForEach(p => p.ChildrenMenu = GetChildMenu(p, siteMenus));

                //vwSiteMenus = (from p in siteMenus
                //               where p.ParentID.Value==parentID
                //               select new VM.SiteMenu
                //               {
                //                   ActionName = string.IsNullOrEmpty(p.ActionName) ? string.Empty : p.ActionName,
                //                   Area = string.IsNullOrEmpty(p.Area) ? string.Empty : p.Area,
                //                   Controller = string.IsNullOrEmpty(p.Controller) ? string.Empty : p.Controller,
                //                   MenuID = p.MenuID,
                //                   ParentID = p.ParentID,
                //                   ResourceKey = string.IsNullOrEmpty(p.ResourceKey) ? string.Empty : p.ResourceKey,
                //                   RouteValues = string.IsNullOrEmpty(p.RouteValues) ? string.Empty : p.RouteValues,
                //                   IsSkip = p.IsSkip,
                //                   DisplayOrder = p.DisplayOrder,
                //                   ChildrenMenu=GetChildMenu(p.MenuID,siteMenus)
                //               }).OrderBy(p => p.DisplayOrder).ToList();
            }
            return(vwSiteMenus);
        }
Example #2
0
 private bool IsExists(VM.Common.SiteMenu siteMenu, List <MD.vw_Authen_RolePermissions> rolePermissions, int i)
 {
     return(rolePermissions.Any(p =>
     {
         //HasActionPermission
         if (p.HasActionPermission)  //add by zack 20190325
         {
             if (p.Area.Equals(siteMenu.Area, StringComparison.InvariantCultureIgnoreCase) &&
                 p.Controller.Equals(siteMenu.Controller, StringComparison.InvariantCultureIgnoreCase) &&
                 p.ActionName.Equals(siteMenu.ActionName, StringComparison.InvariantCultureIgnoreCase))
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
         else
         {
             //add by zack 20190325
             if (p.Area.Equals(siteMenu.Area, StringComparison.InvariantCultureIgnoreCase) &&
                 p.Controller.Equals(siteMenu.Controller, StringComparison.InvariantCultureIgnoreCase))
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
     }));
 }
Example #3
0
        private List <VM.Common.SiteMenu> ConvertToVMMenu(IEnumerable <MD.Common_SiteMap_Menu> siteMenus, VM.Common.SiteMenu parentMenu)
        {
            List <VM.Common.SiteMenu> vwSiteMenus = (from p in siteMenus
                                                     select new VM.Common.SiteMenu
            {
                ActionName = string.IsNullOrEmpty(p.ActionName) ? string.Empty : p.ActionName,
                Area = string.IsNullOrEmpty(p.Area) ? string.Empty : p.Area,
                Controller = string.IsNullOrEmpty(p.Controller) ? string.Empty : p.Controller,
                MenuID = p.MenuID,
                ParentID = p.ParentID,
                ParentMenu = parentMenu,
                ResourceKey = string.IsNullOrEmpty(p.ResourceKey) ? string.Empty : p.ResourceKey,
                RouteValues = string.IsNullOrEmpty(p.RouteValues) ? string.Empty : p.RouteValues,
                IsSkip = p.IsSkip,
                DisplayOrder = p.DisplayOrder
            }).OrderBy(p => p.DisplayOrder).ToList();

            return(vwSiteMenus);
        }