protected virtual IShipmentPackageStateMergePatched Map(IMergePatchShipmentPackage c) { var stateEventId = new ShipmentPackageEventId(c.ShipmentPackageId, c.Version); IShipmentPackageStateMergePatched e = NewShipmentPackageStateMergePatched(stateEventId); e.ShipmentBoxTypeId = c.ShipmentBoxTypeId; e.DateCreated = c.DateCreated; e.BoxLength = c.BoxLength; e.BoxHeight = c.BoxHeight; e.BoxWidth = c.BoxWidth; e.DimensionUomId = c.DimensionUomId; e.Weight = c.Weight; e.WeightUomId = c.WeightUomId; e.InsuredValue = c.InsuredValue; e.Active = c.Active; e.IsPropertyShipmentBoxTypeIdRemoved = c.IsPropertyShipmentBoxTypeIdRemoved; e.IsPropertyDateCreatedRemoved = c.IsPropertyDateCreatedRemoved; e.IsPropertyBoxLengthRemoved = c.IsPropertyBoxLengthRemoved; e.IsPropertyBoxHeightRemoved = c.IsPropertyBoxHeightRemoved; e.IsPropertyBoxWidthRemoved = c.IsPropertyBoxWidthRemoved; e.IsPropertyDimensionUomIdRemoved = c.IsPropertyDimensionUomIdRemoved; e.IsPropertyWeightRemoved = c.IsPropertyWeightRemoved; e.IsPropertyWeightUomIdRemoved = c.IsPropertyWeightUomIdRemoved; e.IsPropertyInsuredValueRemoved = c.IsPropertyInsuredValueRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (IShipmentPackageContentCommand innerCommand in c.ShipmentPackageContentCommands) { ThrowOnInconsistentCommands(c, innerCommand); IShipmentPackageContentEvent innerEvent = Map(innerCommand, c, version, _state); e.AddShipmentPackageContentEvent(innerEvent); } return(e); }
public virtual ShipmentPackageStateMergePatchedDto ToShipmentPackageStateMergePatchedDto(IShipmentPackageStateMergePatched e) { var dto = new ShipmentPackageStateMergePatchedDto(); dto.ShipmentPackageEventId = e.ShipmentPackageEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.ShipmentBoxTypeId = e.ShipmentBoxTypeId; dto.DateCreated = e.DateCreated; dto.BoxLength = e.BoxLength; dto.BoxHeight = e.BoxHeight; dto.BoxWidth = e.BoxWidth; dto.DimensionUomId = e.DimensionUomId; dto.Weight = e.Weight; dto.WeightUomId = e.WeightUomId; dto.InsuredValue = e.InsuredValue; dto.Active = e.Active; dto.IsPropertyShipmentBoxTypeIdRemoved = e.IsPropertyShipmentBoxTypeIdRemoved; dto.IsPropertyDateCreatedRemoved = e.IsPropertyDateCreatedRemoved; dto.IsPropertyBoxLengthRemoved = e.IsPropertyBoxLengthRemoved; dto.IsPropertyBoxHeightRemoved = e.IsPropertyBoxHeightRemoved; dto.IsPropertyBoxWidthRemoved = e.IsPropertyBoxWidthRemoved; dto.IsPropertyDimensionUomIdRemoved = e.IsPropertyDimensionUomIdRemoved; dto.IsPropertyWeightRemoved = e.IsPropertyWeightRemoved; dto.IsPropertyWeightUomIdRemoved = e.IsPropertyWeightUomIdRemoved; dto.IsPropertyInsuredValueRemoved = e.IsPropertyInsuredValueRemoved; dto.IsPropertyActiveRemoved = e.IsPropertyActiveRemoved; var shipmentPackageContentEvents = new List <ShipmentPackageContentStateCreatedOrMergePatchedOrRemovedDto>(); foreach (var ee in e.ShipmentPackageContentEvents) { ShipmentPackageContentStateCreatedOrMergePatchedOrRemovedDto eeDto = ShipmentPackageContentStateEventDtoConverter.ToShipmentPackageContentStateEventDto(ee); shipmentPackageContentEvents.Add(eeDto); } dto.ShipmentPackageContentEvents = shipmentPackageContentEvents.ToArray(); return(dto); }
void IShipmentPackageState.When(IShipmentPackageStateMergePatched e) { throw new NotSupportedException(); }
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); } } }
public virtual void MergePatch(IMergePatchShipmentPackage c) { IShipmentPackageStateMergePatched e = Map(c); Apply(e); }