@@ -349,7 +349,7 @@ protected async Task<IActionResult> InternalAdd(string prefix, RepresentationPar
349349 _logger . LogInformation ( Global . AddResource ) ;
350350 try
351351 {
352- var command = new AddRepresentationCommand ( _resourceType , jobj , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm ) ;
352+ var command = new AddRepresentationCommand ( _resourceType , jobj , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm , IsPublishEvtsEnabled ) ;
353353 var addRepresentationResult = await _addRepresentationCommandHandler . Handle ( command ) ;
354354 if ( addRepresentationResult . HasError ) return this . BuildError ( addRepresentationResult ) ;
355355 var representation = addRepresentationResult . Result ;
@@ -398,13 +398,17 @@ protected async Task<IActionResult> InternalDelete(string prefix, string id, Can
398398 _logger . LogInformation ( string . Format ( Global . DeleteResource , id ) ) ;
399399 try
400400 {
401- var getRepresentationResult = await _deleteRepresentationCommandHandler . Handle ( new DeleteRepresentationCommand ( id , _resourceType , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm ) ) ;
401+ var getRepresentationResult = await _deleteRepresentationCommandHandler . Handle ( new DeleteRepresentationCommand ( id , _resourceType , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm , IsPublishEvtsEnabled ) ) ;
402402 if ( getRepresentationResult . HasError ) return this . BuildError ( getRepresentationResult ) ;
403403 var representation = getRepresentationResult . Result ;
404404 representation . ApplyEmptyArray ( ) ;
405405 var location = GetLocation ( realm , representation ) ;
406406 var content = representation . ToResponse ( location , false , mergeExtensionAttributes : _options . MergeExtensionAttributes ) ;
407- if ( IsPublishEvtsEnabled ) await _busControl . Publish ( new RepresentationRemovedEvent ( id , representation . Version , GetResourceType ( _resourceType ) , realm , content , _options . IncludeToken ? Request . GetToken ( ) : string . Empty ) ) ;
407+ if ( IsPublishEvtsEnabled )
408+ {
409+ await _busControl . Publish ( new RepresentationRemovedEvent ( id , representation . Version , GetResourceType ( _resourceType ) , realm , content , _options . IncludeToken ? Request . GetToken ( ) : string . Empty ) ) ;
410+ }
411+
408412 return new StatusCodeResult ( ( int ) HttpStatusCode . NoContent ) ;
409413 }
410414 catch ( SCIMSchemaViolatedException ex )
@@ -442,7 +446,7 @@ protected async Task<IActionResult> InternalUpdate(string prefix, string id, Rep
442446 _logger . LogInformation ( Global . UpdateResource , id ) ;
443447 try
444448 {
445- var updateResult = await _replaceRepresentationCommandHandler . Handle ( new ReplaceRepresentationCommand ( id , _resourceType , representationParameter , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm ) ) ;
449+ var updateResult = await _replaceRepresentationCommandHandler . Handle ( new ReplaceRepresentationCommand ( id , _resourceType , representationParameter , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm , IsPublishEvtsEnabled ) ) ;
446450 if ( updateResult . HasError ) return this . BuildError ( updateResult ) ;
447451 if ( ! updateResult . Result . IsReplaced ) return NoContent ( ) ;
448452 var representation = updateResult . Result . Representation ;
@@ -515,7 +519,7 @@ protected async Task<IActionResult> InternalPatch(string prefix, string id, Patc
515519 _logger . LogInformation ( string . Format ( Global . PatchResource , id , patchRepresentation == null ? string . Empty : JsonSerializer . Serialize ( patchRepresentation ) ) ) ;
516520 try
517521 {
518- var patchRes = await _patchRepresentationCommandHandler . Handle ( new PatchRepresentationCommand ( id , ResourceType , patchRepresentation , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm ) ) ;
522+ var patchRes = await _patchRepresentationCommandHandler . Handle ( new PatchRepresentationCommand ( id , ResourceType , patchRepresentation , _uriProvider . GetAbsoluteUriWithVirtualPath ( ) , realm , IsPublishEvtsEnabled ) ) ;
519523 if ( patchRes . HasError ) return this . BuildError ( patchRes ) ;
520524 var patchResult = patchRes . Result ;
521525 if ( ! patchResult . IsPatched ) return NoContent ( ) ;
@@ -525,9 +529,7 @@ protected async Task<IActionResult> InternalPatch(string prefix, string id, Patc
525529 if ( ! _options . IsFullRepresentationReturned )
526530 {
527531 var content = representation . ToResponse ( location , true , mergeExtensionAttributes : _options . MergeExtensionAttributes ) ;
528- if ( IsPublishEvtsEnabled )
529- await _busControl . Publish ( new RepresentationUpdatedEvent ( representation . Id , representation . Version , GetResourceType ( _resourceType ) , realm , content , _options . IncludeToken ? Request . GetToken ( ) : string . Empty , patchRes . Result . PatchOperations ) ) ;
530-
532+ if ( IsPublishEvtsEnabled ) await _busControl . Publish ( new RepresentationUpdatedEvent ( representation . Id , representation . Version , GetResourceType ( _resourceType ) , realm , content , _options . IncludeToken ? Request . GetToken ( ) : string . Empty , patchRes . Result . PatchOperations ) ) ;
531533 return BuildHTTPResult ( HttpStatusCode . OK , location , representation . Version , content ) ;
532534 }
533535 else
0 commit comments