Open
Description
Description
Raise domain events directly from domain entities, following Clean Architecture and Domain-Driven Design (DDD) principles. Avoid raising events in the business logic of CQRS Handlers; instead, ensure that entities themselves are responsible for emitting events when their state changes.
Scope
- Implement domain events for key state transitions, such as
IsComplete
andIsChanging
(e.g.,FormUpdatingEvent
,FormUpdatedEvent
). - Leverage
MediatRDomainEventDispatcher
as infrastructure to dispatch events, and consider how EF Core can be used to process these events in a centralized and consistent manner. - Ensure that event raising is encapsulated within the domain model, not in application or handler logic.
References
- Clean Architecture by Robert C. Martin
- Domain-Driven Design by Eric Evans
- Vertical Slice Architecture
Acceptance Criteria
- Domain events are raised from entities, not from CQRS handlers.
- State transitions like
IsComplete
andIsChanging
are covered by events. - Event dispatching is handled centrally using infrastructure (e.g., MediatR, EF Core hooks).
- Code is clean, maintainable, and follows SOLID and DDD best practices.