}// END ThrowOnInconsistentCommands ///////////////////// protected void ThrowOnInconsistentCommands(IShipmentReceiptCommand command, IShipmentReceiptImageCommand innerCommand) { var properties = command as ICreateOrMergePatchOrRemoveShipmentReceipt; var innerProperties = innerCommand as ICreateOrMergePatchOrRemoveShipmentReceiptImage; if (properties == null || innerProperties == null) { return; } if (innerProperties.ShipmentId == default(string)) { innerProperties.ShipmentId = properties.ShipmentId; } else { var outerShipmentIdName = "ShipmentId"; var outerShipmentIdValue = properties.ShipmentId; var innerShipmentIdName = "ShipmentId"; var innerShipmentIdValue = innerProperties.ShipmentId; ThrowOnInconsistentIds(innerProperties, innerShipmentIdName, innerShipmentIdValue, outerShipmentIdName, outerShipmentIdValue); } if (innerProperties.ShipmentReceiptReceiptSeqId == default(string)) { innerProperties.ShipmentReceiptReceiptSeqId = properties.ReceiptSeqId; } else { var outerReceiptSeqIdName = "ReceiptSeqId"; var outerReceiptSeqIdValue = properties.ReceiptSeqId; var innerShipmentReceiptReceiptSeqIdName = "ShipmentReceiptReceiptSeqId"; var innerShipmentReceiptReceiptSeqIdValue = innerProperties.ShipmentReceiptReceiptSeqId; ThrowOnInconsistentIds(innerProperties, innerShipmentReceiptReceiptSeqIdName, innerShipmentReceiptReceiptSeqIdValue, outerReceiptSeqIdName, outerReceiptSeqIdValue); } }// END ThrowOnInconsistentCommands /////////////////////
}// END Map(IMergePatch... //////////////////////////// protected virtual IShipmentReceiptEvent Map(IShipmentReceiptCommand c, IShipmentCommand outerCommand, long version, IShipmentState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateShipmentReceipt) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchShipmentReceipt) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } throw new NotSupportedException(); }
public void Remove(IShipmentReceiptCommand c) { _innerCommands.Remove(c); }
public void Add(IShipmentReceiptCommand c) { _innerCommands.Add(c); }
}// END Map(IMergePatch... //////////////////////////// protected virtual IShipmentReceiptImageStateRemoved MapRemove(IRemoveShipmentReceiptImage c, IShipmentReceiptCommand outerCommand, long version) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new ShipmentReceiptImageEventId(c.ShipmentId, c.ShipmentReceiptReceiptSeqId, c.SequenceId, version); IShipmentReceiptImageStateRemoved e = NewShipmentReceiptImageStateRemoved(stateEventId); e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IRemove... ////////////////////////////
}// END Map(ICreate... //////////////////////////// protected virtual IShipmentReceiptImageStateMergePatched MapMergePatch(IMergePatchShipmentReceiptImage c, IShipmentReceiptCommand outerCommand, long version, IShipmentReceiptState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new ShipmentReceiptImageEventId(c.ShipmentId, c.ShipmentReceiptReceiptSeqId, c.SequenceId, version); IShipmentReceiptImageStateMergePatched e = NewShipmentReceiptImageStateMergePatched(stateEventId); var s = outerState.ShipmentReceiptImages.Get(c.SequenceId); e.Url = c.Url; e.Active = c.Active; e.IsPropertyUrlRemoved = c.IsPropertyUrlRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
void IShipmentReceiptCommands.Remove(IShipmentReceiptCommand c) { _innerCommands.Remove((CreateOrMergePatchOrRemoveShipmentReceiptDto)c); }