public ActionResult Create() { ViewBag.Selected = ""; ViewBag.urlValue = url; ViewBag.MenuFunctionList = _MenuFunctionService.GetAllActive().ToList(); return(View()); }
public ActionResult Create(string group = "") { ViewBag.Selected = ""; ViewBag.GroupID = group; ViewBag.MenuFunctionList = _MenuFunctionService.GetAllActive().ToList(); return(View()); }
public PartialViewResult Breadcrumb(string controller = "", string action = "", string group = "") { //Điều hướng string groupname = ""; string direct = FunctionHelper.DirectActionByGroup(group, ref groupname); ViewBag.DirectValue = direct; controller = FunctionHelper.ConverControllerInGroup(controller); //Danh sách menu var list = new List <MenuFunction>(); if (CacheLayer.Exists(ConstField.AllListMenuFunctionCache)) { list = CacheLayer.Get <List <MenuFunction> >(ConstField.AllListMenuFunctionCache); } else { list = _MenuFunctionService.GetAllActive().ToList(); CacheLayer.Add(ConstField.AllListMenuFunctionCache, list, ConstField.TimeCache); } var listModel = new List <SelectListModel2>(); var obj = list.FirstOrDefault(n => n.ControllerName.Equals(controller) && n.ActionName.Equals(action)); var breadcrumb = GetBreadcrumb(obj != null ? obj.ParentId.ToString() : "0", ""); if (!string.IsNullOrWhiteSpace(breadcrumb)) { var id = breadcrumb.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (id.Any()) { foreach (var item in id.Reverse()) { var objF = list.FirstOrDefault(n => n.Id.Equals(item)); if (objF != null) { listModel.Add(new SelectListModel2 { ItemText = objF.MenuName, ItemValue = controller, ItemSecondValue = objF.isSystem ? 1 : 0 }); } } } } ViewBag.ObjName = obj != null ? obj.MenuName : ""; ViewBag.isSystem = obj != null ? obj.isSystem : false; ViewBag.GroupIDValue = group; return(PartialView(listModel)); }
public ActionResult Header(string controllerName = "", string actionName = "") { var list = new List <MenuFunction>(); if (CacheLayer.Exists(ConstField.AllListMenuFunctionCache)) { list = CacheLayer.Get <List <MenuFunction> >(ConstField.AllListMenuFunctionCache); } else { list = _MenuFunctionService.GetAllActive().ToList(); CacheLayer.Add(ConstField.AllListMenuFunctionCache, list, ConstField.TimeCache); } var obj = _MenuFunctionService.GetByControllerAction(controllerName, actionName); return(PartialView(obj)); }
private List <MenuFunctionSubmit> GetMenuList() { var Dictionary = FunctionHelper.GetLocalizeDictionary("SelectList", "menuFunction"); var list = new List <MenuFunctionSubmit> { new MenuFunctionSubmit { Id = "0", MenuName = Dictionary["menuFunction"] } }; var MenuList = _MenuFunctionService.GetAllActive(); var parent = MenuList.Where(c => c.ParentId == "0"); if (parent.Any()) { foreach (var item in parent.OrderBy(c => c.OrderNumber)) { //Nếu có thì duyệt tiếp để lưu vào list list.Add(new MenuFunctionSubmit { Id = item.Id, MenuName = item.MenuName }); //Gọi action để lấy danh sách submenu theo id var submenu = Children(item.Id); //Kiểm tra có submenu không if (submenu.Count > 0) { //Nếu có thì duyệt tiếp để lưu vào list foreach (var item1 in submenu) { list.Add(new MenuFunctionSubmit { Id = item1.Id, MenuName = item.MenuName + " / " + item1.MenuName }); } //Phân tách các danh mục list.Add(new MenuFunctionSubmit { Id = "-1", MenuName = "-----" }); } else { //Phân tách các danh mục list.Add(new MenuFunctionSubmit { Id = "-1", MenuName = "-----" }); } } } return(list); }