public IWarehouseState Get(string id) { IWarehouseState state = CurrentSession.Get <WarehouseState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IWarehouseState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public static TDeleteWarehouse ToDeleteWarehouse <TDeleteWarehouse>(this IWarehouseState state) where TDeleteWarehouse : IDeleteWarehouse, new() { var cmd = new TDeleteWarehouse(); cmd.WarehouseId = state.WarehouseId; cmd.Version = ((IWarehouseStateProperties)state).Version; return(cmd); }
public IWarehouseState Get(string id) { IWarehouseState state = CurrentSession.Get <WarehouseState> (id); if (state == null) { state = new WarehouseState(); (state as WarehouseState).WarehouseId = id; } return(state); }
public void Save(IWarehouseState state) { CurrentSession.SaveOrUpdate(state); var saveable = state as ISaveable; if (saveable != null) { saveable.Save(); } }
public static TCreateWarehouse ToCreateWarehouse <TCreateWarehouse>(this IWarehouseState state) where TCreateWarehouse : ICreateWarehouse, new() { var cmd = new TCreateWarehouse(); cmd.Version = ((IWarehouseStateProperties)state).Version; cmd.WarehouseId = state.WarehouseId; cmd.Name = state.Name; cmd.Description = state.Description; cmd.IsInTransit = state.IsInTransit; cmd.Active = ((IWarehouseStateProperties)state).Active; return(cmd); }
public IWarehouseState Get(string id, bool nullAllowed) { IWarehouseState state = CurrentSession.Get <WarehouseState> (id); if (!nullAllowed && state == null) { state = new WarehouseState(); (state as WarehouseState).WarehouseId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IWarehouseState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IWarehouseState> GetAsync(string warehouseId) { IWarehouseState state = null; var idObj = warehouseId; var uriParameters = new WarehouseUriParameters(); uriParameters.Id = idObj; var req = new WarehouseGetRequest(uriParameters); var resp = await _ramlClient.Warehouse.Get(req); WarehouseProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToWarehouseState(); return(state); }
public void Save(IWarehouseState state) { IWarehouseState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IWarehouseState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } }
public static TMergePatchWarehouse ToMergePatchWarehouse <TMergePatchWarehouse>(this IWarehouseState state) where TMergePatchWarehouse : IMergePatchWarehouse, new() { var cmd = new TMergePatchWarehouse(); cmd.Version = ((IWarehouseStateProperties)state).Version; cmd.WarehouseId = state.WarehouseId; cmd.Name = state.Name; cmd.Description = state.Description; cmd.IsInTransit = state.IsInTransit; cmd.Active = ((IWarehouseStateProperties)state).Active; if (state.Name == null) { cmd.IsPropertyNameRemoved = true; } if (state.Description == null) { cmd.IsPropertyDescriptionRemoved = true; } return(cmd); }
public abstract IWarehouseAggregate GetWarehouseAggregate(IWarehouseState state);
public override IWarehouseAggregate GetWarehouseAggregate(IWarehouseState state) { return(new WarehouseAggregate(state)); }
public WarehouseAggregate(IWarehouseState state) { _state = state; }
public WarehouseStateDtoWrapper(IWarehouseState state) { this._state = state; }
public WarehouseStateDtoWrapper() { this._state = new WarehouseState(); }
protected bool IsRepeatedCommand(IWarehouseCommand command, IEventStoreAggregateId eventStoreAggregateId, IWarehouseState state) { bool repeated = false; if (((IWarehouseStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IWarehouseEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IWarehouseAggregate aggregate, IWarehouseState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IWarehouseStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IWarehouseAggregate, IWarehouseState>(aggregate, state, aggregate.Changes)); } }
public static IWarehouseCommand ToCreateOrMergePatchWarehouse <TCreateWarehouse, TMergePatchWarehouse>(this IWarehouseState state) where TCreateWarehouse : ICreateWarehouse, new() where TMergePatchWarehouse : IMergePatchWarehouse, new() { bool bUnsaved = ((IWarehouseState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateWarehouse <TCreateWarehouse>()); } else { return(state.ToMergePatchWarehouse <TMergePatchWarehouse>()); } }