Skip to content

Tutorial 4: Defining Business Logic Workflows as Domain Models :: Commands and Events

cdmdotnet edited this page Mar 20, 2016 · 3 revisions

Domain Modelling

Domain modelling here is the process of taking a workflow diagram and defining attributes that tell Visual Studio the intent of objects and data like properties and data types.

Commands and Events

Since commands and events are the core of any CQRS system, it's best to start with these two types of objects.

Business logic improved

Referring back to our diagram from step 2, we have two commands and four events:

  • Commands
    • WithdrawFundsFromAtm
    • WithdrawFundsFromAccount
  • Events
    • WithdrawFailedDueAmountLessThanZero
    • WithdrawValidated
    • WithdrawFailedDueInsufficientFunds
    • WithdrawFundsFromAccountSucceeded

To create a command

  • Create classes for each command in the Command package.
  • Apply the Command stereotype.
  • Add an Attribute names Amount and set the Type to System::double

To create an event

  • Create classes for each event in the Event package.
  • Apply the Event stereotype.

Adding New Command Classes

Adding an Amount property and applying the System:double Type

All commands and events

Clone this wiki locally