public virtual void Initialize(IShipmentPackageStateCreated stateCreated) { var aggregateId = stateCreated.ShipmentPackageEventId.ShipmentPackageId; var state = new ShipmentPackageState(); state.ShipmentPackageId = aggregateId; var aggregate = (ShipmentPackageAggregate)GetShipmentPackageAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual IShipmentPackageState ToShipmentPackageState() { var state = new ShipmentPackageState(true); state.ShipmentPackageId = this.ShipmentPackageId; state.ShipmentBoxTypeId = this.ShipmentBoxTypeId; state.DateCreated = this.DateCreated; state.BoxLength = this.BoxLength; state.BoxHeight = this.BoxHeight; state.BoxWidth = this.BoxWidth; state.DimensionUomId = this.DimensionUomId; state.Weight = this.Weight; state.WeightUomId = this.WeightUomId; state.InsuredValue = this.InsuredValue; if (this.Active != null && this.Active.HasValue) { state.Active = this.Active.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.ShipmentPackageContents != null) { foreach (var s in this.ShipmentPackageContents) { state.ShipmentPackageContents.AddToSave(s.ToShipmentPackageContentState()); } } ; return(state); }
public static CreateShipmentPackage ToCreateShipmentPackage(this ShipmentPackageState state) { return(state.ToCreateShipmentPackage <CreateShipmentPackage, CreateShipmentPackageContent>()); }
public static MergePatchShipmentPackage ToMergePatchShipmentPackage(this ShipmentPackageState state) { return(state.ToMergePatchShipmentPackage <MergePatchShipmentPackage, CreateShipmentPackageContent, MergePatchShipmentPackageContent>()); }
public static DeleteShipmentPackage ToDeleteShipmentPackage(this ShipmentPackageState state) { return(state.ToDeleteShipmentPackage <DeleteShipmentPackage>()); }
public static IShipmentPackageCommand ToCreateOrMergePatchShipmentPackage(this ShipmentPackageState state) { return(state.ToCreateOrMergePatchShipmentPackage <CreateShipmentPackage, MergePatchShipmentPackage, CreateShipmentPackageContent, MergePatchShipmentPackageContent>()); }