Esempio n. 1
0
        public ResponseViewModel OperUserGroup(TreePostData postData)
        {
            ResponseViewModel vm = new ResponseViewModel();

            if (postData.Operation == TreeNodeOper.DELETE_NODE)
            {
                vm.success = _rbacService.DeleteUserGroup(postData.Id);
            }
            else if (postData.Operation == TreeNodeOper.CREATE_NODE)
            {
                FapUserGroup userGroup = new FapUserGroup()
                {
                    Pid           = postData.Id,
                    UserGroupName = postData.Text
                };
                _rbacService.CreateUserGroup(userGroup);
                vm.success = true;
                vm.data    = userGroup.Fid;
            }
            else if (postData.Operation == TreeNodeOper.RENAME_NODE)
            {
                var userGroup = _dbContext.Get <FapUserGroup>(postData.Id);
                userGroup.UserGroupName = postData.Text;
                vm.success = _rbacService.EditUserGroup(userGroup);
            }
            else if (postData.Operation == "move_node")
            {
                var userGroup = _dbContext.Get <FapUserGroup>(postData.Id);
                userGroup.Pid = postData.Parent;
                vm.success    = _rbacService.EditUserGroup(userGroup);
            }
            else if (postData.Operation == TreeNodeOper.COPY_NODE)
            {
                throw new NotImplementedException();
            }
            return(vm);
        }