public virtual void When(IShipmentPackageStateCreated e) { ThrowOnWrongEvent(e); this.ShipmentBoxTypeId = e.ShipmentBoxTypeId; this.DateCreated = e.DateCreated; this.BoxLength = e.BoxLength; this.BoxHeight = e.BoxHeight; this.BoxWidth = e.BoxWidth; this.DimensionUomId = e.DimensionUomId; this.Weight = e.Weight; this.WeightUomId = e.WeightUomId; this.InsuredValue = e.InsuredValue; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.Deleted = false; this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IShipmentPackageContentStateCreated innerEvent in e.ShipmentPackageContentEvents) { IShipmentPackageContentState innerState = this.ShipmentPackageContents.Get(innerEvent.GlobalId.ShipmentItemSeqId, true); innerState.Mutate(innerEvent); } }
public virtual void When(IShipmentPackageStateMergePatched e) { ThrowOnWrongEvent(e); if (e.ShipmentBoxTypeId == null) { if (e.IsPropertyShipmentBoxTypeIdRemoved) { this.ShipmentBoxTypeId = default(string); } } else { this.ShipmentBoxTypeId = e.ShipmentBoxTypeId; } if (e.DateCreated == null) { if (e.IsPropertyDateCreatedRemoved) { this.DateCreated = default(DateTime?); } } else { this.DateCreated = e.DateCreated; } if (e.BoxLength == null) { if (e.IsPropertyBoxLengthRemoved) { this.BoxLength = default(decimal?); } } else { this.BoxLength = e.BoxLength; } if (e.BoxHeight == null) { if (e.IsPropertyBoxHeightRemoved) { this.BoxHeight = default(decimal?); } } else { this.BoxHeight = e.BoxHeight; } if (e.BoxWidth == null) { if (e.IsPropertyBoxWidthRemoved) { this.BoxWidth = default(decimal?); } } else { this.BoxWidth = e.BoxWidth; } if (e.DimensionUomId == null) { if (e.IsPropertyDimensionUomIdRemoved) { this.DimensionUomId = default(string); } } else { this.DimensionUomId = e.DimensionUomId; } if (e.Weight == null) { if (e.IsPropertyWeightRemoved) { this.Weight = default(decimal?); } } else { this.Weight = e.Weight; } if (e.WeightUomId == null) { if (e.IsPropertyWeightUomIdRemoved) { this.WeightUomId = default(string); } } else { this.WeightUomId = e.WeightUomId; } if (e.InsuredValue == null) { if (e.IsPropertyInsuredValueRemoved) { this.InsuredValue = default(decimal?); } } else { this.InsuredValue = e.InsuredValue; } if (e.Active == null) { if (e.IsPropertyActiveRemoved) { this.Active = default(bool); } } else { this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); } this.UpdatedBy = e.CreatedBy; this.UpdatedAt = e.CreatedAt; foreach (IShipmentPackageContentEvent innerEvent in e.ShipmentPackageContentEvents) { IShipmentPackageContentState innerState = this.ShipmentPackageContents.Get(innerEvent.GlobalId.ShipmentItemSeqId); innerState.Mutate(innerEvent); var removed = innerEvent as IShipmentPackageContentStateRemoved; if (removed != null) { this.ShipmentPackageContents.Remove(innerState); } } }