public IPicklistBinState Get(string id) { IPicklistBinState state = CurrentSession.Get <PicklistBinState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IPicklistBinState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public static TDeletePicklistBin ToDeletePicklistBin <TDeletePicklistBin>(this IPicklistBinState state) where TDeletePicklistBin : IDeletePicklistBin, new() { var cmd = new TDeletePicklistBin(); cmd.PicklistBinId = state.PicklistBinId; cmd.Version = ((IPicklistBinStateProperties)state).Version; return(cmd); }
public DtoPicklistItemStates(IPicklistBinState outerState, IEnumerable <IPicklistItemState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IPicklistItemState[] { }; } else { this._innerStates = innerStates; } }
public IPicklistBinState Get(string id, bool nullAllowed) { IPicklistBinState state = CurrentSession.Get <PicklistBinState> (id); if (!nullAllowed && state == null) { state = new PicklistBinState(); (state as PicklistBinState).PicklistBinId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IPicklistBinState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IPicklistBinState> GetAsync(string picklistBinId) { IPicklistBinState state = null; var idObj = picklistBinId; var uriParameters = new PicklistBinUriParameters(); uriParameters.Id = idObj; var req = new PicklistBinGetRequest(uriParameters); var resp = await _ramlClient.PicklistBin.Get(req); PicklistBinProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToPicklistBinState(); return(state); }
public void Save(IPicklistBinState state) { IPicklistBinState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IPicklistBinState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
protected bool IsRepeatedCommand(IPicklistBinCommand command, IEventStoreAggregateId eventStoreAggregateId, IPicklistBinState state) { bool repeated = false; if (((IPicklistBinStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IPicklistBinEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IPicklistBinAggregate aggregate, IPicklistBinState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IPicklistBinStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IPicklistBinAggregate, IPicklistBinState>(aggregate, state, aggregate.Changes)); } }
public abstract IPicklistBinAggregate GetPicklistBinAggregate(IPicklistBinState state);
public static TMergePatchPicklistBin ToMergePatchPicklistBin <TMergePatchPicklistBin, TCreatePicklistItem, TMergePatchPicklistItem>(this IPicklistBinState state) where TMergePatchPicklistBin : IMergePatchPicklistBin, new() where TCreatePicklistItem : ICreatePicklistItem, new() where TMergePatchPicklistItem : IMergePatchPicklistItem, new() { var cmd = new TMergePatchPicklistBin(); cmd.Version = ((IPicklistBinStateProperties)state).Version; cmd.PicklistBinId = state.PicklistBinId; cmd.PicklistId = state.PicklistId; cmd.BinLocationNumber = state.BinLocationNumber; cmd.PrimaryOrderId = state.PrimaryOrderId; cmd.PrimaryShipGroupSeqId = state.PrimaryShipGroupSeqId; cmd.Active = ((IPicklistBinStateProperties)state).Active; if (state.PicklistId == null) { cmd.IsPropertyPicklistIdRemoved = true; } if (state.BinLocationNumber == null) { cmd.IsPropertyBinLocationNumberRemoved = true; } if (state.PrimaryOrderId == null) { cmd.IsPropertyPrimaryOrderIdRemoved = true; } if (state.PrimaryShipGroupSeqId == null) { cmd.IsPropertyPrimaryShipGroupSeqIdRemoved = true; } foreach (var d in state.PicklistItems) { var c = d.ToCreateOrMergePatchPicklistItem <TCreatePicklistItem, TMergePatchPicklistItem>(); cmd.PicklistItemCommands.Add(c); } return(cmd); }
public PicklistBinAggregate(IPicklistBinState state) { _state = state; }
}// END Map(ICreate... //////////////////////////// protected virtual IPicklistItemStateMergePatched MapMergePatch(IMergePatchPicklistItem c, IPicklistBinCommand outerCommand, long version, IPicklistBinState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new PicklistItemEventId(c.PicklistBinId, c.PicklistItemOrderShipGrpInvId, version); IPicklistItemStateMergePatched e = NewPicklistItemStateMergePatched(stateEventId); var s = outerState.PicklistItems.Get(c.PicklistItemOrderShipGrpInvId); e.ItemStatusId = c.ItemStatusId; e.Quantity = c.Quantity; e.Active = c.Active; e.IsPropertyItemStatusIdRemoved = c.IsPropertyItemStatusIdRemoved; e.IsPropertyQuantityRemoved = c.IsPropertyQuantityRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
public static IPicklistBinCommand ToCreateOrMergePatchPicklistBin <TCreatePicklistBin, TMergePatchPicklistBin, TCreatePicklistItem, TMergePatchPicklistItem>(this IPicklistBinState state) where TCreatePicklistBin : ICreatePicklistBin, new() where TMergePatchPicklistBin : IMergePatchPicklistBin, new() where TCreatePicklistItem : ICreatePicklistItem, new() where TMergePatchPicklistItem : IMergePatchPicklistItem, new() { bool bUnsaved = ((IPicklistBinState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreatePicklistBin <TCreatePicklistBin, TCreatePicklistItem>()); } else { return(state.ToMergePatchPicklistBin <TMergePatchPicklistBin, TCreatePicklistItem, TMergePatchPicklistItem>()); } }
public PicklistBinStateDtoWrapper(IPicklistBinState state) { this._state = state; }
public PicklistBinStateDtoWrapper() { this._state = new PicklistBinState(); }
public override IPicklistBinAggregate GetPicklistBinAggregate(IPicklistBinState state) { return(new PicklistBinAggregate(state)); }
public static TCreatePicklistBin ToCreatePicklistBin <TCreatePicklistBin, TCreatePicklistItem>(this IPicklistBinState state) where TCreatePicklistBin : ICreatePicklistBin, new() where TCreatePicklistItem : ICreatePicklistItem, new() { var cmd = new TCreatePicklistBin(); cmd.Version = ((IPicklistBinStateProperties)state).Version; cmd.PicklistBinId = state.PicklistBinId; cmd.PicklistId = state.PicklistId; cmd.BinLocationNumber = state.BinLocationNumber; cmd.PrimaryOrderId = state.PrimaryOrderId; cmd.PrimaryShipGroupSeqId = state.PrimaryShipGroupSeqId; cmd.Active = ((IPicklistBinStateProperties)state).Active; foreach (var d in state.PicklistItems) { var c = d.ToCreatePicklistItem <TCreatePicklistItem>(); cmd.PicklistItems.Add(c); } return(cmd); }
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IPicklistItemEvent Map(IPicklistItemCommand c, IPicklistBinCommand outerCommand, long version, IPicklistBinState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreatePicklistItem) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchPicklistItem) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemovePicklistItem) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
public PicklistItemStates(IPicklistBinState outerState) { this._picklistBinState = outerState; this._forReapplying = outerState.ForReapplying; }