Example #1
0
        public async Task <AddRoleOutput> AddRole(AddRoleInput input)
        {
            Role role = new Role(input.Name)
            {
                DisplayName = input.DisplayName,
                Describe    = input.DisplayName
            };

            await _roleManager.CreateRole(role);

            return(new AddRoleOutput());
        }
Example #2
0
        public void Add(AddRoleInput input)
        {
            input.Validate();
            Sys_Role role = this.CreateEntity <Sys_Role>();

            this.MapValueFromInput(role, input);

            string[] permissionIds = input.GetPermissionIds();
            List <Sys_RoleAuthorize> roleAuthorizeEntitys = this.CreateRoleAuthorizes(role.Id, permissionIds);

            this.DbContext.DoWithTransaction(() =>
            {
                this.DbContext.Insert(role);

                foreach (var roleAuthorizeEntity in roleAuthorizeEntitys)
                {
                    this.DbContext.Insert(roleAuthorizeEntity);
                }
            });
        }
Example #3
0
        public async Task <AddRoleOutput> AddRole(AddRoleInput input)
        {
            var admin = _adminManager.GetAdmin(input.AdminId);

            if (admin == null)
            {
                throw new Exception("找不到要添加权限的管理员");
            }

            var role = _roleManager.GetRole(input.RoleId);

            if (role == null)
            {
                throw new Exception("找不到要添加的权限");
            }

            _adminManager.AddRole(admin, role);

            return(new AddRoleOutput());
        }
Example #4
0
        //[ValidateAntiForgeryToken]
        public ActionResult Add(AddRoleInput input)
        {
            input.Validate();
            var      services = CreateService <IAccountAppService>();
            Sys_Role role     = new Sys_Role();

            AceMapper.Map(input, role);
            role.CreateUserId = CurrentSession.UserId;
            role.CreateTime   = DateTime.Now;
            services.Insert(role);
            string[] permissionIds = input.GetPermissionIds();
            List <Sys_RoleAuthorize> roleAuthorizeEntitys = CreateRoleAuthorizes(role.Id, permissionIds);

            foreach (var roleAuthorizeEntity in roleAuthorizeEntitys)
            {
                services.Insert(roleAuthorizeEntity);
            }

            return(AddSuccessMsg());
        }
Example #5
0
        public IActionResult Add([FromBody] AddRoleInput role)
        {
            int id = _roleService.Add(role);

            return(Created("", new { id }));
        }
Example #6
0
 //[ValidateAntiForgeryToken]
 public ActionResult Add(AddRoleInput input)
 {
     this.CreateService <IRoleAppService>().Add(input);
     return(this.AddSuccessMsg());
 }
Example #7
0
 public ActionResult Add(AddRoleInput input)
 {
     input.CreateUserId = this.CurrentSession.UserId;
     this.Service.Add(input);
     return(this.AddSuccessMsg());
 }
Example #8
0
 public ActionResult Add(AddRoleInput input)
 {
     this.Service.Add(input);
     return(this.AddSuccessMsg());
 }