Exemplo n.º 1
0
        public IHttpActionResult Post([FromBody] dynamic data)
        {
            //JsonSerializer serializer = new JsonSerializer();

            Action action = actionService.Add(new Action()
            {
                //ActionName = data["ActionName"].Value,
                //Url = data["Url"].Value,
            });
            //把权限给系统管理员
            RoleService roleservice = new RoleService();
            var         role        = roleservice.GetEntities(u => u.Id == 1).FirstOrDefault();

            role.Action.Add(action);
            roleservice.Update(role);
            if (action == null)
            {
                return(Ok(new
                {
                    code = 0,
                    data = ""
                }));
            }
            return(Ok(new { code = 1 }));
        }
Exemplo n.º 2
0
        public void InitializeAction()
        {
            ActionService actionService = new ActionService();

            Model.Action action = actionService.Add(new Model.Action
            {
                ActionType = "menu"
            });
            //关联Menu菜单和权限
            MenuService menuService = new MenuService();

            menuService.GetEntities(u => u.Id > 0).ToList().ForEach(m => m.Action.Add(action));
            Model.Action module = actionService.Add(new Model.Action
            {
                ActionType = "module"
            });
            //关联ActionModule表和Action表
            ActionModuleService actionModuleService = new ActionModuleService();

            actionModuleService.GetEntities(u => u.Id > 0).ToList().ForEach(m => m.Action.Add(module));
        }