1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMISOnline.DataLogic.SystemDAL;
- using EMISOnline.Entities;
- using EMISOnline.ViewModel;
- using System.Linq.Expressions;
- using EMISOnline.CommonLogic;
- using EMISOnline.DataLogic.SystemDAL;
- namespace EMISOnline.CommonLogic.SystemServices
- {
- public class MenuServices : BaseServices, IMenuServices
- {
- public MenuDAL MenuDAL { get; set; }
- public IList<Sys_Menu> GetMenuByUserID(Guid userID)
- {
- Expression<Func<Sys_Menu, bool>> menuDefineExp = (x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- Expression<Func<Sys_User, bool>> userExp = (x => x.UserID == userID);
- return MenuDAL.GetMenuByUser(menuDefineExp, userExp).OrderBy(x => x.ParentMenuNo).ThenBy(x => x.OrderNo).ToList();
- }
- public string GetFullMenuPath(string menuNo)
- {
- var menu = MenuDAL.MenuRepository.GetSingle(x => x.MenuNo == menuNo);
- var menuList = MenuDAL.MenuRepository.Entities.ToList();
- return this.GetParentMenuName(menu, menuList);
- }
- private string GetParentMenuName(Sys_Menu menu, IList<Sys_Menu> menuList)
- {
- if (menu != null)
- {
- if ((menu.ParentMenuNo ?? "") != "")
- {
- var parentMenu = menuList.Where(x => x.MenuNo == menu.ParentMenuNo).FirstOrDefault();
- return this.GetParentMenuName(parentMenu, menuList) + " -> " + menu.MenuName;
- }
- return menu.MenuName;
- }
- else
- {
- return "";
- }
- }
- }
- }
|