public async Task <List <BoundStatement> > BuildBoundStatements_ForDelete( Scope scope) { var result = new List <BoundStatement>(); FlattenedScopeHandle fsh = new FlattenedScopeHandle(scope); FlattenedScopeRecord fsr = new FlattenedScopeRecord(fsh); PreparedStatement prepared = await _DeleteScopeById; BoundStatement bound = prepared.Bind(fsr.Id); result.Add(bound); prepared = await _DeleteScopeByName; bound = prepared.Bind(scope.Name); result.Add(bound); return(result); }
public async Task <List <BoundStatement> > BuildBoundStatements_ForScopeClaimCreate( FlattenedScopeRecord scopeRecord) { var result = new List <BoundStatement>(); var scope = scopeRecord.Record; // var scopeSecretsDocument = new SimpleDocument<List<Secret>>(scope.ScopeSecrets); // var claimsDocument = new SimpleDocument<List<ScopeClaim>>(scope.Claims); int scopeType = (int)scope.Type; var scopeInternal = await scopeRecord.Record.GetScopeAsync(); var claimsQuery = from scopeClaim in scopeInternal.Claims select new ScopeClaimRecord(scopeRecord.Id, scopeRecord.Record.Name, scopeClaim); var scopeClaimBoundStatements = await BuildBoundStatements_ForScopeClaimRecord_Create(claimsQuery); result.AddRange(scopeClaimBoundStatements); return(result); }
public async Task <bool> UpsertScopeAsync(FlattenedScopeRecord scopeRecord, CancellationToken cancellationToken = default(CancellationToken)) { try { var session = CassandraSession; cancellationToken.ThrowIfCancellationRequested(); if (scopeRecord == null) { throw new ArgumentNullException("scopeRecord"); } // breaking batch apart. var batch = new BatchStatement(); var boundStatements = await BuildBoundStatements_ForCreate(scopeRecord); batch.AddRange(boundStatements); cancellationToken.ThrowIfCancellationRequested(); #if _SCOPE_CLAIMS_TABLE boundStatements = await BuildBoundStatements_ForScopeClaimCreate(scopeRecord); batch.AddRange(boundStatements); await session.ExecuteAsync(batch).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); #endif await session.ExecuteAsync(batch).ConfigureAwait(false); return(true); } catch (Exception e) { throw; } }