Esempio n. 1
0
        private State ApplyEvent(State state, EventPayload payload)
        {
            switch (payload)
            {
            case AuctionCreated auctionCreated:
                return(CreatedState.Create(
                           auctionCreated.Auction.EndTime,
                           auctionCreated.Auction.StartingPrice));

            case BidPlaced bidPlaced:
                return(CreatedState.WithHighestBid(state as CreatedState, bidPlaced.Bid.Amount));

            default:
                throw new Exception("Unknown event type");
            }
        }
Esempio n. 2
0
 public static CreatedState WithHighestBid(CreatedState state, decimal amount)
 {
     return(new CreatedState(state.EndTime, state.StartingPrice, amount));
 }