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"); } }
public static CreatedState WithHighestBid(CreatedState state, decimal amount) { return(new CreatedState(state.EndTime, state.StartingPrice, amount)); }