public async Task <RoleClaimsResponseResult> AddClaimsToRole( [FromBody] IEnumerable <ApplicationRoleClaim> roleClaims) { foreach (var rc in roleClaims) { var res1 = await _roleManager.AddClaimAsync( new ApplicationRole() { Id = rc.RoleId }, new System.Security.Claims.Claim( rc.ClaimType, rc.ClaimValue)); if (!res1.Succeeded) { return(new RoleClaimsResponseResult() { Code = 400, Message = res1.Errors?.FirstOrDefault()?.Description }); } } return(new RoleClaimsResponseResult() { Code = 400, Data = roleClaims.ToArray() }); }
public async Task <ApplicationRoleClaim> AddRoleClaim([FromBody] ApplicationRoleClaim roleClaim) { var result = await _roleManager.AddClaimAsync(new ApplicationRole() { Id = roleClaim.Id }, new System.Security.Claims.Claim(roleClaim.ClaimType, roleClaim.ClaimValue)); if (result.Succeeded) { return(roleClaim); } return(null); }