Skip to content

Extract Catalog stock validation service#11

Open
mattfromcursor wants to merge 1 commit into
mainfrom
cursor/extract-catalog-stock-validation-198f
Open

Extract Catalog stock validation service#11
mattfromcursor wants to merge 1 commit into
mainfrom
cursor/extract-catalog-stock-validation-198f

Conversation

@mattfromcursor

@mattfromcursor mattfromcursor commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Plan

Summary

Extract Catalog stock validation from OrderStatusChangedToAwaitingValidationIntegrationEventHandler into a dedicated ICatalogStockValidationService implementation while leaving event contracts, RabbitMQ subscriptions, and ICatalogIntegrationEventService outbox/publish behavior unchanged.

Files

  • src/Catalog.API/IntegrationEvents/ICatalogStockValidationService.cs - new interface for stock validation.
  • src/Catalog.API/IntegrationEvents/CatalogStockValidationService.cs - new implementation that loads catalog items and returns either OrderStockRejectedIntegrationEvent or OrderStockConfirmedIntegrationEvent.
  • src/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs - delegate validation to the service, then save and publish through ICatalogIntegrationEventService exactly as before.
  • src/Catalog.API/Extensions/Extensions.cs - register ICatalogStockValidationService with DI.

Interface methods

  • Task<IntegrationEvent> ValidateStockAsync(int orderId, IEnumerable<OrderStockItem> orderStockItems)

DI

  • Add builder.Services.AddTransient<ICatalogStockValidationService, CatalogStockValidationService>(); in src/Catalog.API/Extensions/Extensions.cs alongside the Catalog integration-event services.

Risks to event publishing

  • Preserve SaveEventAndCatalogContextChangesAsync(...) followed by PublishThroughEventBusAsync(...) in the handler to avoid changing outbox persistence and publish ordering.
  • Do not change ICatalogIntegrationEventService, EventBus contracts, event records, or Ordering.API consumers.
  • Keep RabbitMQ subscription registration unchanged so OrderStatusChangedToAwaitingValidationIntegrationEvent continues to reach the same handler.

Build output

Requested command

dotnet restore eShop.Web.slnf && dotnet build eShop.Web.slnf

Result: blocked by environment/network access before compilation. NuGet vulnerability audit could not reach https://api.nuget.org/v3/index.json, producing NU1900 warnings as errors across solution projects.

Representative output:

  • /workspace/src/Catalog.API/Catalog.API.csproj : error NU1900: Warning As Error: Error occurred while getting package vulnerability data: Unable to load the service index for source https://api.nuget.org/v3/index.json.
  • Failed to restore ...

Compile verification fallback

dotnet restore eShop.Web.slnf -p:NuGetAudit=false && dotnet build eShop.Web.slnf --no-restore -p:NuGetAudit=false -p:LibraryRestore=False

Result: build succeeded after disabling external NuGet audit and LibMan cdnjs restore for this network-restricted environment.

Output:

  • Catalog.API -> /workspace/artifacts/bin/Catalog.API/debug/Catalog.API.dll
  • eShop.AppHost -> /workspace/artifacts/bin/eShop.AppHost/debug/eShop.AppHost.dll
  • Build succeeded.
  • 0 Warning(s)
  • 0 Error(s)
Open in Web Open in Cursor 

Co-authored-by: mattfromcursor <mattfromcursor@users.noreply.github.com>
@mattfromcursor mattfromcursor marked this pull request as ready for review June 4, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants