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()); }
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); } }); }
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()); }
//[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()); }
public IActionResult Add([FromBody] AddRoleInput role) { int id = _roleService.Add(role); return(Created("", new { id })); }
//[ValidateAntiForgeryToken] public ActionResult Add(AddRoleInput input) { this.CreateService <IRoleAppService>().Add(input); return(this.AddSuccessMsg()); }
public ActionResult Add(AddRoleInput input) { input.CreateUserId = this.CurrentSession.UserId; this.Service.Add(input); return(this.AddSuccessMsg()); }
public ActionResult Add(AddRoleInput input) { this.Service.Add(input); return(this.AddSuccessMsg()); }