Exemple #1
0
        public async Task AddToRoleAsync(User user, string roleName, CancellationToken cancellationToken)
        {
            var role = await _rolesStore.FindByNameAsync(roleName, cancellationToken);

            if (role == null)
            {
                throw new Exception($"Role does not exist {roleName}");
            }

            await _repo.ExecuteAsync(
                _helper.GetAddUserToRoleSql(role),
                cancellationToken,
                new { userId = user.Id, role.Id });
        }