public virtual IInventoryItemRequirementState ToInventoryItemRequirementState() { var state = new InventoryItemRequirementState(true); state.InventoryItemRequirementId = this.InventoryItemRequirementId; if (this.Quantity != null && this.Quantity.HasValue) { state.Quantity = this.Quantity.Value; } if (this.Version != null && this.Version.HasValue) { state.Version = this.Version.Value; } state.CreatedBy = this.CreatedBy; if (this.CreatedAt != null && this.CreatedAt.HasValue) { state.CreatedAt = this.CreatedAt.Value; } state.UpdatedBy = this.UpdatedBy; if (this.UpdatedAt != null && this.UpdatedAt.HasValue) { state.UpdatedAt = this.UpdatedAt.Value; } if (this.Entries != null) { foreach (var s in this.Entries) { state.Entries.AddToSave(s.ToInventoryItemRequirementEntryState()); } } ; return(state); }
public virtual void Initialize(IInventoryItemRequirementStateCreated stateCreated) { var aggregateId = stateCreated.InventoryItemRequirementEventId.InventoryItemRequirementId; var state = new InventoryItemRequirementState(); state.InventoryItemRequirementId = aggregateId; var aggregate = (InventoryItemRequirementAggregate)GetInventoryItemRequirementAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }