public virtual void When(IOrderShipmentStateCreated e) { ThrowOnWrongEvent(e); this.Quantity = e.Quantity; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; }
public virtual OrderShipmentStateCreatedDto ToOrderShipmentStateCreatedDto(IOrderShipmentStateCreated e) { var dto = new OrderShipmentStateCreatedDto(); dto.OrderShipmentEventId = e.OrderShipmentEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.Quantity = e.Quantity; dto.Active = e.Active; return(dto); }
public virtual void Initialize(IOrderShipmentStateCreated stateCreated) { var aggregateId = stateCreated.OrderShipmentEventId.OrderShipmentId; var state = new OrderShipmentState(); state.OrderShipmentId = aggregateId; var aggregate = (OrderShipmentAggregate)GetOrderShipmentAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
protected virtual IOrderShipmentStateCreated Map(ICreateOrderShipment c) { var stateEventId = new OrderShipmentEventId(c.OrderShipmentId, c.Version); IOrderShipmentStateCreated e = NewOrderShipmentStateCreated(stateEventId); e.Quantity = c.Quantity; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; return(e); }
public virtual void Create(ICreateOrderShipment c) { IOrderShipmentStateCreated e = Map(c); Apply(e); }
void IOrderShipmentState.When(IOrderShipmentStateCreated e) { throw new NotSupportedException(); }