Example #1
0
        public ActionResult EditRGroup(RoleGroupModel model)
        {
            ViewData["Roles"] = roleService.GetRoles();
            //验证
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //获取权限
            int[] roles  = Array.ConvertAll(Request["Role"].Split(new string[] { ",", "false" }, StringSplitOptions.RemoveEmptyEntries), s => Convert.ToInt32(s));
            int   result = 0;

            //修改
            if (model.RG_no != null)
            {
                result = RGroupService.UpdateRoleGroup(Convert.ToInt32(model.RG_no), model.RG_name, roles);
            }
            //新增
            else
            {
                result = RGroupService.InsertGroup(model.RG_name, roles);
            }
            if (result != 0)
            {
                return(RedirectToAction("RoleGroupList"));
            }
            return(View(model));
        }
Example #2
0
        /// <summary>
        /// 新增管理权限组
        /// </summary>
        /// <returns></returns>
        public ActionResult InsertRoleGroup()
        {
            string     name  = Request["name"];
            List <int> roles = JsonConvert.DeserializeObject <List <int> >(Request["roles"]);


            if (!string.IsNullOrEmpty(name))
            {
                return(Content(RGroupService.InsertGroup(name, roles).ToString()));
            }
            return(Content("0"));
        }