Beispiel #1
0
        public async Task <ClaimResult> AssignClaimTo <TEntity>(TEntity entity, IEnumerable <T> claims) where TEntity : class
        {
            switch (entity.GetType().Name)
            {
            case "User":
                var user = entity as User;
                if (user is null)
                {
                    goto default;
                }
                return(await claimsManager.AssignClaimsToUserAsync(user, claims));

            case "Role":
                var role = entity as Role;
                if (role is null)
                {
                    goto default;
                }
                return(await claimsManager.AssignClaimsToRoleAsync(role, claims));

            default:
                return(new ClaimResult()
                {
                    Succeed = false
                });
            }
        }