}// END Map(ICreate... //////////////////////////// protected virtual IShipmentReceiptStateMergePatched MapMergePatch(IMergePatchShipmentReceipt c, IShipmentCommand outerCommand, long version, IShipmentState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new ShipmentReceiptEventId(c.ShipmentId, c.ReceiptSeqId, version); IShipmentReceiptStateMergePatched e = NewShipmentReceiptStateMergePatched(stateEventId); var s = outerState.ShipmentReceipts.Get(c.ReceiptSeqId); e.ProductId = c.ProductId; e.AttributeSetInstanceId = c.AttributeSetInstanceId; e.LocatorId = c.LocatorId; e.ShipmentItemSeqId = c.ShipmentItemSeqId; e.ShipmentPackageSeqId = c.ShipmentPackageSeqId; e.OrderId = c.OrderId; e.OrderItemSeqId = c.OrderItemSeqId; e.ReturnId = c.ReturnId; e.ReturnItemSeqId = c.ReturnItemSeqId; e.RejectionReasonId = c.RejectionReasonId; e.DamageStatusIds = c.DamageStatusIds; e.DamageReasonId = c.DamageReasonId; e.ReceivedBy = c.ReceivedBy; e.DatetimeReceived = c.DatetimeReceived; e.ItemDescription = c.ItemDescription; e.AcceptedQuantity = c.AcceptedQuantity; e.RejectedQuantity = c.RejectedQuantity; e.DamagedQuantity = c.DamagedQuantity; e.Active = c.Active; e.IsPropertyProductIdRemoved = c.IsPropertyProductIdRemoved; e.IsPropertyAttributeSetInstanceIdRemoved = c.IsPropertyAttributeSetInstanceIdRemoved; e.IsPropertyLocatorIdRemoved = c.IsPropertyLocatorIdRemoved; e.IsPropertyShipmentItemSeqIdRemoved = c.IsPropertyShipmentItemSeqIdRemoved; e.IsPropertyShipmentPackageSeqIdRemoved = c.IsPropertyShipmentPackageSeqIdRemoved; e.IsPropertyOrderIdRemoved = c.IsPropertyOrderIdRemoved; e.IsPropertyOrderItemSeqIdRemoved = c.IsPropertyOrderItemSeqIdRemoved; e.IsPropertyReturnIdRemoved = c.IsPropertyReturnIdRemoved; e.IsPropertyReturnItemSeqIdRemoved = c.IsPropertyReturnItemSeqIdRemoved; e.IsPropertyRejectionReasonIdRemoved = c.IsPropertyRejectionReasonIdRemoved; e.IsPropertyDamageStatusIdsRemoved = c.IsPropertyDamageStatusIdsRemoved; e.IsPropertyDamageReasonIdRemoved = c.IsPropertyDamageReasonIdRemoved; e.IsPropertyReceivedByRemoved = c.IsPropertyReceivedByRemoved; e.IsPropertyDatetimeReceivedRemoved = c.IsPropertyDatetimeReceivedRemoved; e.IsPropertyItemDescriptionRemoved = c.IsPropertyItemDescriptionRemoved; e.IsPropertyAcceptedQuantityRemoved = c.IsPropertyAcceptedQuantityRemoved; e.IsPropertyRejectedQuantityRemoved = c.IsPropertyRejectedQuantityRemoved; e.IsPropertyDamagedQuantityRemoved = c.IsPropertyDamagedQuantityRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); foreach (IShipmentReceiptImageCommand innerCommand in c.ShipmentReceiptImageCommands) { ThrowOnInconsistentCommands(c, innerCommand); IShipmentReceiptImageEvent innerEvent = Map(innerCommand, c, version, s); e.AddShipmentReceiptImageEvent(innerEvent); } return(e); }// END Map(IMergePatch... ////////////////////////////
protected void ThrowOnWrongEvent(IShipmentReceiptImageEvent e) { var id = new System.Text.StringBuilder(); id.Append("[").Append("ShipmentReceiptImage|"); var stateEntityIdShipmentId = (this as IGlobalIdentity <ShipmentReceiptImageId>).GlobalId.ShipmentId; var eventEntityIdShipmentId = e.ShipmentReceiptImageEventId.ShipmentId; if (stateEntityIdShipmentId != eventEntityIdShipmentId) { throw DomainError.Named("mutateWrongEntity", "Entity Id ShipmentId {0} in state but entity id ShipmentId {1} in event", stateEntityIdShipmentId, eventEntityIdShipmentId); } id.Append(stateEntityIdShipmentId).Append(","); var stateEntityIdShipmentReceiptReceiptSeqId = (this as IGlobalIdentity <ShipmentReceiptImageId>).GlobalId.ShipmentReceiptReceiptSeqId; var eventEntityIdShipmentReceiptReceiptSeqId = e.ShipmentReceiptImageEventId.ShipmentReceiptReceiptSeqId; if (stateEntityIdShipmentReceiptReceiptSeqId != eventEntityIdShipmentReceiptReceiptSeqId) { throw DomainError.Named("mutateWrongEntity", "Entity Id ShipmentReceiptReceiptSeqId {0} in state but entity id ShipmentReceiptReceiptSeqId {1} in event", stateEntityIdShipmentReceiptReceiptSeqId, eventEntityIdShipmentReceiptReceiptSeqId); } id.Append(stateEntityIdShipmentReceiptReceiptSeqId).Append(","); var stateEntityIdSequenceId = (this as IGlobalIdentity <ShipmentReceiptImageId>).GlobalId.SequenceId; var eventEntityIdSequenceId = e.ShipmentReceiptImageEventId.SequenceId; if (stateEntityIdSequenceId != eventEntityIdSequenceId) { throw DomainError.Named("mutateWrongEntity", "Entity Id SequenceId {0} in state but entity id SequenceId {1} in event", stateEntityIdSequenceId, eventEntityIdSequenceId); } id.Append(stateEntityIdSequenceId).Append(","); id.Append("]"); if (ForReapplying) { return; } var stateVersion = this.Version; var stateEvent = e is IShipmentReceiptImageStateEvent ? (IShipmentReceiptImageStateEvent)e : null; if (e == null) { return; } stateEvent.Version = stateVersion; //var stateEventStateVersion = stateEvent.Version; //if (ShipmentReceiptImageState.VersionZero == stateEventStateVersion) //{ // stateEventStateVersion = stateEvent.Version = stateVersion; //} //if (stateVersion != stateEventStateVersion) //{ // throw OptimisticConcurrencyException.Create(stateVersion, stateEventStateVersion, id.ToString()); //} }
public void Save(IShipmentReceiptImageEvent stateEvent) { CurrentSession.Save(stateEvent); var saveable = stateEvent as ISaveable; if (saveable != null) { saveable.Save(); } }
public static void ThrowOnInconsistentEventIds(IShipmentReceiptEvent oe, IShipmentReceiptImageEvent e) { if (!oe.ShipmentReceiptEventId.ShipmentId.Equals(e.ShipmentReceiptImageEventId.ShipmentId)) { throw DomainError.Named("inconsistentEventIds", "Outer Id ShipmentId {0} but inner id ShipmentId {1}", oe.ShipmentReceiptEventId.ShipmentId, e.ShipmentReceiptImageEventId.ShipmentId); } if (!oe.ShipmentReceiptEventId.ReceiptSeqId.Equals(e.ShipmentReceiptImageEventId.ShipmentReceiptReceiptSeqId)) { throw DomainError.Named("inconsistentEventIds", "Outer Id ReceiptSeqId {0} but inner id ShipmentReceiptReceiptSeqId {1}", oe.ShipmentReceiptEventId.ReceiptSeqId, e.ShipmentReceiptImageEventId.ShipmentReceiptReceiptSeqId); } }
void IShipmentReceiptStateMergePatched.AddShipmentReceiptImageEvent(IShipmentReceiptImageEvent e) { this._shipmentReceiptImageEvents.AddShipmentReceiptImageEvent(e); }
public void AddShipmentReceiptImageEvent(IShipmentReceiptImageEvent e) { _innerStateEvents.Add((ShipmentReceiptImageStateCreatedOrMergePatchedOrRemovedDto)e); }
public virtual void AddShipmentReceiptImageEvent(IShipmentReceiptImageEvent e) { ThrowOnInconsistentEventIds(e); this._shipmentReceiptImageEvents[e.ShipmentReceiptImageEventId] = e; }
protected void ThrowOnInconsistentEventIds(IShipmentReceiptImageEvent e) { ThrowOnInconsistentEventIds(this, e); }
public virtual ShipmentReceiptImageStateCreatedOrMergePatchedOrRemovedDto ToShipmentReceiptImageStateEventDto(IShipmentReceiptImageEvent stateEvent) { if (stateEvent.EventType == StateEventType.Created) { var e = (IShipmentReceiptImageStateCreated)stateEvent; return(ToShipmentReceiptImageStateCreatedDto(e)); } else if (stateEvent.EventType == StateEventType.MergePatched) { var e = (IShipmentReceiptImageStateMergePatched)stateEvent; return(ToShipmentReceiptImageStateMergePatchedDto(e)); } else if (stateEvent.EventType == StateEventType.Removed) { var e = (IShipmentReceiptImageStateRemoved)stateEvent; return(ToShipmentReceiptImageStateRemovedDto(e)); } throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType)); }