public IShipmentPackageState Get(ShipmentPackageId id) { IShipmentPackageState state = CurrentSession.Get <ShipmentPackageState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IShipmentPackageState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public DtoShipmentPackageContentStates(IShipmentPackageState outerState, IEnumerable <IShipmentPackageContentState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IShipmentPackageContentState[] { }; } else { this._innerStates = innerStates; } }
public IShipmentPackageState Get(ShipmentPackageId id, bool nullAllowed) { IShipmentPackageState state = CurrentSession.Get <ShipmentPackageState> (id); if (!nullAllowed && state == null) { state = new ShipmentPackageState(); (state as ShipmentPackageState).ShipmentPackageId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IShipmentPackageState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IShipmentPackageState> GetAsync(ShipmentPackageId shipmentPackageId) { IShipmentPackageState state = null; var idObj = ShipmentPackageProxyUtils.ToIdString(shipmentPackageId); var uriParameters = new ShipmentPackageUriParameters(); uriParameters.Id = idObj; var req = new ShipmentPackageGetRequest(uriParameters); var resp = await _ramlClient.ShipmentPackage.Get(req); ShipmentPackageProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToShipmentPackageState(); return(state); }
public void Save(IShipmentPackageState state) { IShipmentPackageState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IShipmentPackageState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
public ShipmentPackageStateDtoWrapper() { this._state = new ShipmentPackageState(); }
public static TMergePatchShipmentPackage ToMergePatchShipmentPackage <TMergePatchShipmentPackage, TCreateShipmentPackageContent, TMergePatchShipmentPackageContent>(this IShipmentPackageState state) where TMergePatchShipmentPackage : IMergePatchShipmentPackage, new() where TCreateShipmentPackageContent : ICreateShipmentPackageContent, new() where TMergePatchShipmentPackageContent : IMergePatchShipmentPackageContent, new() { var cmd = new TMergePatchShipmentPackage(); cmd.Version = ((IShipmentPackageStateProperties)state).Version; cmd.ShipmentPackageId = state.ShipmentPackageId; cmd.ShipmentBoxTypeId = state.ShipmentBoxTypeId; cmd.DateCreated = state.DateCreated; cmd.BoxLength = state.BoxLength; cmd.BoxHeight = state.BoxHeight; cmd.BoxWidth = state.BoxWidth; cmd.DimensionUomId = state.DimensionUomId; cmd.Weight = state.Weight; cmd.WeightUomId = state.WeightUomId; cmd.InsuredValue = state.InsuredValue; cmd.Active = ((IShipmentPackageStateProperties)state).Active; if (state.ShipmentBoxTypeId == null) { cmd.IsPropertyShipmentBoxTypeIdRemoved = true; } if (state.DateCreated == null) { cmd.IsPropertyDateCreatedRemoved = true; } if (state.BoxLength == null) { cmd.IsPropertyBoxLengthRemoved = true; } if (state.BoxHeight == null) { cmd.IsPropertyBoxHeightRemoved = true; } if (state.BoxWidth == null) { cmd.IsPropertyBoxWidthRemoved = true; } if (state.DimensionUomId == null) { cmd.IsPropertyDimensionUomIdRemoved = true; } if (state.Weight == null) { cmd.IsPropertyWeightRemoved = true; } if (state.WeightUomId == null) { cmd.IsPropertyWeightUomIdRemoved = true; } if (state.InsuredValue == null) { cmd.IsPropertyInsuredValueRemoved = true; } foreach (var d in state.ShipmentPackageContents) { var c = d.ToCreateOrMergePatchShipmentPackageContent <TCreateShipmentPackageContent, TMergePatchShipmentPackageContent>(); cmd.ShipmentPackageContentCommands.Add(c); } return(cmd); }
public static TDeleteShipmentPackage ToDeleteShipmentPackage <TDeleteShipmentPackage>(this IShipmentPackageState state) where TDeleteShipmentPackage : IDeleteShipmentPackage, new() { var cmd = new TDeleteShipmentPackage(); cmd.ShipmentPackageId = state.ShipmentPackageId; cmd.Version = ((IShipmentPackageStateProperties)state).Version; return(cmd); }
public static IShipmentPackageCommand ToCreateOrMergePatchShipmentPackage <TCreateShipmentPackage, TMergePatchShipmentPackage, TCreateShipmentPackageContent, TMergePatchShipmentPackageContent>(this IShipmentPackageState state) where TCreateShipmentPackage : ICreateShipmentPackage, new() where TMergePatchShipmentPackage : IMergePatchShipmentPackage, new() where TCreateShipmentPackageContent : ICreateShipmentPackageContent, new() where TMergePatchShipmentPackageContent : IMergePatchShipmentPackageContent, new() { bool bUnsaved = ((IShipmentPackageState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateShipmentPackage <TCreateShipmentPackage, TCreateShipmentPackageContent>()); } else { return(state.ToMergePatchShipmentPackage <TMergePatchShipmentPackage, TCreateShipmentPackageContent, TMergePatchShipmentPackageContent>()); } }
public static TCreateShipmentPackage ToCreateShipmentPackage <TCreateShipmentPackage, TCreateShipmentPackageContent>(this IShipmentPackageState state) where TCreateShipmentPackage : ICreateShipmentPackage, new() where TCreateShipmentPackageContent : ICreateShipmentPackageContent, new() { var cmd = new TCreateShipmentPackage(); cmd.Version = ((IShipmentPackageStateProperties)state).Version; cmd.ShipmentPackageId = state.ShipmentPackageId; cmd.ShipmentBoxTypeId = state.ShipmentBoxTypeId; cmd.DateCreated = state.DateCreated; cmd.BoxLength = state.BoxLength; cmd.BoxHeight = state.BoxHeight; cmd.BoxWidth = state.BoxWidth; cmd.DimensionUomId = state.DimensionUomId; cmd.Weight = state.Weight; cmd.WeightUomId = state.WeightUomId; cmd.InsuredValue = state.InsuredValue; cmd.Active = ((IShipmentPackageStateProperties)state).Active; foreach (var d in state.ShipmentPackageContents) { var c = d.ToCreateShipmentPackageContent <TCreateShipmentPackageContent>(); cmd.ShipmentPackageContents.Add(c); } return(cmd); }
public ShipmentPackageAggregate(IShipmentPackageState state) { _state = state; }
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IShipmentPackageContentEvent Map(IShipmentPackageContentCommand c, IShipmentPackageCommand outerCommand, long version, IShipmentPackageState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateShipmentPackageContent) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchShipmentPackageContent) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemoveShipmentPackageContent) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IShipmentPackageAggregate aggregate, IShipmentPackageState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IShipmentPackageStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IShipmentPackageAggregate, IShipmentPackageState>(aggregate, state, aggregate.Changes)); } }
public abstract IShipmentPackageAggregate GetShipmentPackageAggregate(IShipmentPackageState state);
public override IShipmentPackageAggregate GetShipmentPackageAggregate(IShipmentPackageState state) { return(new ShipmentPackageAggregate(state)); }
public ShipmentPackageStateDtoWrapper(IShipmentPackageState state) { this._state = state; }
public ShipmentPackageContentStates(IShipmentPackageState outerState) { this._shipmentPackageState = outerState; this._forReapplying = outerState.ForReapplying; }
protected bool IsRepeatedCommand(IShipmentPackageCommand command, IEventStoreAggregateId eventStoreAggregateId, IShipmentPackageState state) { bool repeated = false; if (((IShipmentPackageStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IShipmentPackageEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
}// END Map(ICreate... //////////////////////////// protected virtual IShipmentPackageContentStateMergePatched MapMergePatch(IMergePatchShipmentPackageContent c, IShipmentPackageCommand outerCommand, long version, IShipmentPackageState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new ShipmentPackageContentEventId(c.ShipmentPackageId, c.ShipmentItemSeqId, version); IShipmentPackageContentStateMergePatched e = NewShipmentPackageContentStateMergePatched(stateEventId); var s = outerState.ShipmentPackageContents.Get(c.ShipmentItemSeqId); e.Quantity = c.Quantity; e.SubProductId = c.SubProductId; e.SubProductQuantity = c.SubProductQuantity; e.Active = c.Active; e.IsPropertyQuantityRemoved = c.IsPropertyQuantityRemoved; e.IsPropertySubProductIdRemoved = c.IsPropertySubProductIdRemoved; e.IsPropertySubProductQuantityRemoved = c.IsPropertySubProductQuantityRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////