//To know how this method is called, check ...\EventStore.Core\DddSeedwork\EventSourcedAggregateRoot.cs //Using dynamic we call the "On(event)" method public void On(TicketRegisteredDomainEvent evt) { Id = new TicketId(evt.Id); Title = evt.Title; Description = evt.Description; TicketType = evt.TicketType; TicketState = TicketStateMachineBase.GetTicketState(evt.TicketState); TicketPriority = evt.TicketPriority; User = evt.User; }
public TicketStateChangedDomainEvent(TicketStateMachineBase stateMachine) { State = stateMachine.State; }
public void On(TicketStateChangedDomainEvent evt) { TicketState = TicketStateMachineBase.GetTicketState(evt.State); }
//This is the 'callback' method called from within our ticket state machine. /// <summary> /// Transition state of our ticket after it passed through our state machine. /// Use 'ChangeTicketState' method to properly transition between states. /// </summary> /// <param name="newState"></param> internal void TransitionToState(TicketStateMachineBase newState) { Apply(new TicketStateChangedDomainEvent(newState)); }
//When changing the state of our ticket, this is what the external classes are calling /// <summary> /// Change state of our ticket to the given state. /// </summary> /// <param name="newState"></param> public void ChangeTicketState(TicketState newState) { TicketState.ChangeState(this, TicketStateMachineBase.GetTicketState(newState)); }