Esempio n. 1
0
        /// <summary>
        /// Danh sách sidebar
        /// </summary>
        /// <param name="actionName">Tên action</param>
        /// <param name="controllerName">Tên controller</param>
        /// <param name="openTab">Mở tab lớn khi có chọn con</param>
        /// <returns></returns>
        public PartialViewResult Sidebar(string actionName = "Index", string controllerName = "Home", string openTab = "")
        {
            //All menuFunction
            //var list = CacheLayer.Get<List<MenuFunction>>(ConstField.AllListMenuFunctionCache);
            //if(list==null)
            //{
            //    list = _MenuFunctionService.GetAllActive().ToList();
            //    CacheLayer.Add(ConstField.AllListMenuFunctionCache, list, ConstField.TimeCache);
            //}
            // Current User
            var user = GetCurrentUser.GetUser();

            // get all Role menu buy User
            var model = new List <MenuFunction>();

            if (user != null)
            {
                model = _MenuFunctionService.GetAllMenuByPermisstion(user.Id, user.Admin).Distinct().ToList();
            }

            var pageModel = new PageNameModel
            {
                ControllerName = controllerName,
                ActionName     = actionName,
                OpenMenu       = openTab
            };

            ViewBag.PageModel = pageModel;
            return(PartialView(model));
        }
Esempio n. 2
0
        /// <summary>
        /// Danh sách sidebar
        /// </summary>
        /// <param name="actionName">Tên action</param>
        /// <param name="controllerName">Tên controller</param>
        /// <param name="openTab">Mở tab lớn khi có chọn con</param>
        /// <returns></returns>
        public PartialViewResult Sidebar(string actionName = "Index", string controllerName = "Home", string openTab = "", string group = "")
        {
            // Current User
            var user = GetCurrentUser.GetUser();

            //
            controllerName = FunctionHelper.ConverControllerInGroup(controllerName);

            //Điều hướng
            string groupname = "";
            string direct    = FunctionHelper.DirectActionByGroup(group, ref groupname);

            ViewBag.DirectValue = direct;

            // get all Role menu buy User
            var model = _MenuFunctionService.GetAllMenuByPermisstion(user.Id, user.Admin).Distinct().ToList();

            if (!string.IsNullOrWhiteSpace(group))
            {
                model = model.Where(n => n.MenuGroupListId != null && n.MenuGroupListId.Contains(group)).ToList();
            }
            else
            {
                model = model.Where(n => n.isSystem == true).ToList();
            }

            ViewBag.Controller = controllerName;
            ViewBag.Action     = actionName;
            ViewBag.GroupID    = group;

            var obj = model.FirstOrDefault(n => n.ControllerName.Equals(controllerName) && n.ActionName.Equals(actionName));

            var breadcrumb = GetBreadcrumb(obj != null ? obj.ParentId.ToString() : "0", "");

            ViewBag.Breadcrumb     = string.Format("{0},{1}", obj != null ? obj.Id : "", !string.IsNullOrWhiteSpace(breadcrumb) ? breadcrumb : "");
            ViewBag.GroupNameValue = !string.IsNullOrWhiteSpace(groupname) ? groupname : "Trang chủ";

            return(PartialView(model));
        }