public async Task <IdentityServerStoreAppliedInfo> UpsertAllowedScopeIntoUsersAsync(IdentityServerUserAllowedScope userAllowedScope,
                                                                                            CancellationToken cancellationToken = default(CancellationToken))
        {
            var userExists = await FindDoesUserExistByUserIdAsync(userAllowedScope.UserId, cancellationToken);

            if (!userExists)
            {
                // not allowed
                return(new IdentityServerStoreAppliedInfo
                {
                    Applied = false,
                    Exception = new UserDoesNotExitException()
                });
            }
            var     session = CassandraSession;
            IMapper mapper  = new Mapper(session);

            cancellationToken.ThrowIfCancellationRequested();
            var record = await
                         mapper.InsertIfNotExistsAsync(userAllowedScope);

            return(new IdentityServerStoreAppliedInfo(record.Applied));
        }
        public async Task <IdentityServerStoreAppliedInfo> DeleteAllowedScopeFromUserAsync(IdentityServerUserAllowedScope userAllowedScope,
                                                                                           CancellationToken cancellationToken = default(CancellationToken))
        {
            var userExists = await FindDoesUserExistByUserIdAsync(userAllowedScope.UserId, cancellationToken);

            if (!userExists)
            {
                // not allowed
                return(new IdentityServerStoreAppliedInfo
                {
                    Applied = false,
                    Exception = new UserDoesNotExitException()
                });
            }
            var     session = CassandraSession;
            IMapper mapper  = new Mapper(session);

            cancellationToken.ThrowIfCancellationRequested();
            var record = await
                         mapper.DeleteIfAsync <IdentityServerUserAllowedScope>(
                "WHERE scopename = ? AND userid = ?", userAllowedScope.ScopeName, userAllowedScope.UserId);

            return(new IdentityServerStoreAppliedInfo(record.Applied));
        }