Exemple #1
0
        private static List<Menu> FetchMenuToBind(MenuBindingInfo data, List<Menu> MList)
        {
            //var AllData = (from s in data.MenuList select s).ToList();
            var MainMenus = (from s in data.MenuList select s.MainMenuID).Distinct().ToList();
            foreach (var Menu in MainMenus)
            {
                Menu obj = new Menu();
                var SubmenusForMenu = (from s in data.MenuList where s.MainMenuID == Menu select s).ToList();
                foreach (var submenu in SubmenusForMenu)
                {
                    obj.MainMenuID = submenu.MainMenuID;
                    obj.MainMenuName = submenu.MainMenuName;
                    obj.MainMenuClass = submenu.MainMenuClass;

                    SubMenuBinding SubMenu = new SubMenuBinding();
                    SubMenu.SubMenuID = submenu.SubMenuID;
                    SubMenu.SubMenuName = submenu.SubMenuName;
                    SubMenu.URL = submenu.URL;
                    obj.SubMenuList.Add(SubMenu);
                }
                MList.Add(obj);
            }
            return MList;
        }
Exemple #2
0
        /// <summary>
        /// Description   : To Bind Menu Data
        /// Created By    : Pavan 
        /// Created Date  : 15 September 2014
        /// Modified By   :  
        /// Modified Date :  
        /// <returns></returns>
        /// </summary>
        public static List<Menu> GetMenuDataForUser(int UserID)
        {
            var data = new List<Menu>();

            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
            log.Debug("Start: " + methodBase.Name);
            try
            {
                MenuBindingInfo objMenu = new MenuBindingInfo();
                SqlParameter[] sqlParams = new SqlParameter[1];
                sqlParams[0] = new SqlParameter("@UserID", UserID);

                var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "SpBindMenu", sqlParams);
                var safe = new SafeDataReader(reader);
                while (reader.Read())
                {
                    var Menudata = new MenuBinding();
                    Menudata.FetchMenu(Menudata, safe);
                    objMenu.MenuList.Add(Menudata);
                }

                FetchMenuToBind(objMenu, data);
            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex);
            }
            finally
            {
                log.Debug("End: " + methodBase.Name);
            }
            return data;
        }