public virtual void Initialize(IShipmentTypeStateCreated stateCreated) { var aggregateId = stateCreated.ShipmentTypeEventId.ShipmentTypeId; var state = new ShipmentTypeState(); state.ShipmentTypeId = aggregateId; var aggregate = (ShipmentTypeAggregate)GetShipmentTypeAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual void When(IShipmentTypeStateCreated e) { ThrowOnWrongEvent(e); this.ParentTypeId = e.ParentTypeId; this.HasTable = e.HasTable; this.Description = e.Description; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; }
public virtual ShipmentTypeStateCreatedDto ToShipmentTypeStateCreatedDto(IShipmentTypeStateCreated e) { var dto = new ShipmentTypeStateCreatedDto(); dto.ShipmentTypeEventId = e.ShipmentTypeEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.ParentTypeId = e.ParentTypeId; dto.HasTable = e.HasTable; dto.Description = e.Description; dto.Active = e.Active; return(dto); }
protected virtual IShipmentTypeStateCreated Map(ICreateShipmentType c) { var stateEventId = new ShipmentTypeEventId(c.ShipmentTypeId, c.Version); IShipmentTypeStateCreated e = NewShipmentTypeStateCreated(stateEventId); e.ParentTypeId = c.ParentTypeId; e.HasTable = c.HasTable; e.Description = c.Description; 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); }
void IShipmentTypeState.When(IShipmentTypeStateCreated e) { throw new NotSupportedException(); }
public virtual void Create(ICreateShipmentType c) { IShipmentTypeStateCreated e = Map(c); Apply(e); }