public override Task OnPrepareWriteAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) { if (ExtensibilityPointsToTrack.HasFlag(ResourceDefinitionExtensibilityPoints.OnPrepareWriteAsync)) { _hitCounter.TrackInvocation <TResource>(ResourceDefinitionExtensibilityPoints.OnPrepareWriteAsync); } return(base.OnPrepareWriteAsync(resource, writeOperation, cancellationToken)); }
public override Task OnSetToManyRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet <IIdentifiable> rightResourceIds, WriteOperationKind writeOperation, CancellationToken cancellationToken) { if (ExtensibilityPointsToTrack.HasFlag(ResourceDefinitionExtensibilityPoints.OnSetToManyRelationshipAsync)) { _hitCounter.TrackInvocation <TResource>(ResourceDefinitionExtensibilityPoints.OnSetToManyRelationshipAsync); } return(base.OnSetToManyRelationshipAsync(leftResource, hasManyRelationship, rightResourceIds, writeOperation, cancellationToken)); }
public override async Task OnWriteSucceededAsync(WorkItem resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) { if (writeOperation is not WriteOperationKind.DeleteResource) { await _dbContext.WorkItems.ExecuteAsync(async collection => { resource.Description += Suffix; FilterDefinition <WorkItem> filter = Builders <WorkItem> .Filter.Eq(item => item.Id, resource.Id); await collection.ReplaceOneAsync(filter, resource, cancellationToken: cancellationToken); }); } }
public override async Task OnWriteSucceededAsync(TextLanguage resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) { await base.OnWriteSucceededAsync(resource, writeOperation, cancellationToken); if (writeOperation is not WriteOperationKind.DeleteResource) { resource.IsoCode += Suffix; FilterDefinition <TextLanguage> filter = Builders <TextLanguage> .Filter.Eq(item => item.Id, resource.Id); IMongoCollection <TextLanguage> collection = _mongoDataAccess.MongoDatabase.GetCollection <TextLanguage>(nameof(TextLanguage)); await collection.ReplaceOneAsync(_mongoDataAccess.ActiveSession, filter, resource, cancellationToken : cancellationToken); } }