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 GetMenuByUserID(Guid userID) { Expression> menuDefineExp = (x => x.RecordStatus >= (int)SYS_STATUS.USABLE); Expression> 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 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 ""; } } } }