PlaceBidHandlerOfferBidHandler (moves money into escrow, creates Bid
):
// throws NotFound
account = accounts.Find( cmd.UserId )
// throws InsuficientFunds or raises `BidPlaced``BidOffered`
account.PlaceBidOfferBid( cmd.AuctionId, cmd.LotNumber, cmd.Amount )
SubmitBidHandlerPlaceBidHandler (keeps track of all Bids
or maybe just highest Bid
):
The Auction
(which mediates the process) is simply responsible for reacting to BidPlacedBidOffered
events in a way to trigger SubmitBidPlaceBid
OR RevokeBid
commands (should NotFound
be thrown), and reacting to Outbidded
events in a way to trigger RevokeBid
commands.
If you would like to keep Account
and Auction
in separate contexts (you don't want Account.PlaceBidOfferBid
), this can be modified further to add an extra layer along the lines of: PlaceOrder -> PaymentReceived -> PlaceBid
(in this case ordering a Bid
and debiting account) and BidRevoked -> RefundPayment
to cleanly separate accounts from auctions.