public ActionResult Index(string key, int?page)
        {
            var lst = _MenuFunctionService.GetAllMenu(key);

            //Viewbag
            ViewBag.DDLActive = FunctionHelper.ActiveStatus();
            ViewBag.Keyword   = key;

            url = Request.Url.PathAndQuery;

            return(View(lst));
        }
예제 #2
0
        public PartialViewResult MenuFunctionList(List <MenuFunctionConfig> selected)
        {
            var list = _MenuFunctionService.GetAllMenu("").ToList();

            if (selected.Count == 0)
            {
                selected = _MenuFunctionConfigService.GetAll().ToList();
            }

            ViewBag.selectedValues = selected;

            return(PartialView(list));
        }
예제 #3
0
        public ActionResult Index(string key, int?page, string group = "")
        {
            var lst = _MenuFunctionService.GetAllMenu(key, group);

            //Viewbag
            ViewBag.DDLActive = FunctionHelper.ActiveStatus();
            ViewBag.Keyword   = key;
            //ViewBag.ListMenu = _MenuFunctionService.GetAll().ToList();

            ViewBag.GroupID        = group;
            ViewBag.listGroupAllow = listGroupAllow();

            return(View(lst));
        }
예제 #4
0
        public ActionResult Update(Role obj, string menufunctionvalues, string group = "")
        {
            if (String.IsNullOrEmpty(obj.RoleName) || String.IsNullOrWhiteSpace(obj.RoleName))
            {
                ModelState.AddModelError("", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Role_Name"]);
                Update(obj.Id, group = "");
            }
            //
            ViewBag.Selected = menufunctionvalues;
            ViewBag.GroupID  = group;

            //Kiểm tra
            var oldObj = _RoleService.GetById(obj.Id);

            if (oldObj == null)
            {
                ViewBag.Error        = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                Update(obj.Id, group = "");
            }

            if (!ModelState.IsValid)
            {
                return(View(oldObj));
            }

            //Gán giá trị
            oldObj.RoleName    = obj.RoleName;
            oldObj.Description = obj.Description;
            oldObj.Active      = obj.Active;

            //Cập nhật lại danh sách menu
            var listmenu = _MenuFunctionService.GetAllMenu("", group).Select(n => n.Id).ToList();
            var list     = _RoleMenuService.GetAllByRoleId(obj.Id, listmenu).ToList();

            if (list.Any())
            {
                foreach (var item in list)
                {
                    _RoleMenuService.DeleteById(item.Id);
                }
            }

            if (!string.IsNullOrWhiteSpace(menufunctionvalues))
            {
                string[] ids = menufunctionvalues.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (ids != null)
                {
                    foreach (var item in ids)
                    {
                        RoleMenu objRoleMenu = new RoleMenu();
                        objRoleMenu.Id     = Common.GenerateId();
                        objRoleMenu.RoleId = oldObj.Id;
                        objRoleMenu.MenuId = item;
                        _RoleMenuService.Create(objRoleMenu);
                    }
                }
            }

            //Thực hiện cập nhật
            var result = _RoleService.Update(oldObj);

            if (result)
            {
                var mes = new MessageReport();
                mes.isSuccess = true;
                mes.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["Role_update"];

                var formatRole = string.Format("{0}_{1}", ConstField.ListRoleMenu, oldObj.Id);
                CacheLayer.Clear(formatRole);

                var name = FunctionHelper.getCurrentGroup(group);
                WriteLog.Write(mes, GetCurrentUser.GetUser(), obj.Id, obj.RoleName, "Role", name, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group }));
            }
            else
            {
                ModelState.AddModelError("", FunctionHelper.GetLocalizeDictionary("Home", "notification")["ErMenu"]);
                return(View(oldObj));
            }
        }