public IPhysicalInventoryState Get(string id) { IPhysicalInventoryState state = CurrentSession.Get <PhysicalInventoryState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IPhysicalInventoryState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public DtoPhysicalInventoryLineStates(IPhysicalInventoryState outerState, IEnumerable <IPhysicalInventoryLineState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IPhysicalInventoryLineState[] { }; } else { this._innerStates = innerStates; } }
public IPhysicalInventoryState Get(string id, bool nullAllowed) { IPhysicalInventoryState state = CurrentSession.Get <PhysicalInventoryState> (id); if (!nullAllowed && state == null) { state = new PhysicalInventoryState(); (state as PhysicalInventoryState).DocumentNumber = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IPhysicalInventoryState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IPhysicalInventoryState> GetAsync(string documentNumber) { IPhysicalInventoryState state = null; var idObj = documentNumber; var uriParameters = new PhysicalInventoryUriParameters(); uriParameters.Id = idObj; var req = new PhysicalInventoryGetRequest(uriParameters); var resp = await _ramlClient.PhysicalInventory.Get(req); PhysicalInventoryProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToPhysicalInventoryState(); return(state); }
public void Save(IPhysicalInventoryState state) { IPhysicalInventoryState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IPhysicalInventoryState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
protected bool IsRepeatedCommand(IPhysicalInventoryCommand command, IEventStoreAggregateId eventStoreAggregateId, IPhysicalInventoryState state) { bool repeated = false; if (((IPhysicalInventoryStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IPhysicalInventoryEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IPhysicalInventoryAggregate aggregate, IPhysicalInventoryState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IPhysicalInventoryStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IPhysicalInventoryAggregate, IPhysicalInventoryState>(aggregate, state, aggregate.Changes)); } }
public abstract IPhysicalInventoryAggregate GetPhysicalInventoryAggregate(IPhysicalInventoryState state);
public PhysicalInventoryLineStates(IPhysicalInventoryState outerState) { this._physicalInventoryState = outerState; this._forReapplying = outerState.ForReapplying; }
public static IPhysicalInventoryCommand ToCreateOrMergePatchPhysicalInventory <TCreatePhysicalInventory, TMergePatchPhysicalInventory, TCreatePhysicalInventoryLine, TMergePatchPhysicalInventoryLine>(this IPhysicalInventoryState state) where TCreatePhysicalInventory : ICreatePhysicalInventory, new() where TMergePatchPhysicalInventory : IMergePatchPhysicalInventory, new() where TCreatePhysicalInventoryLine : ICreatePhysicalInventoryLine, new() where TMergePatchPhysicalInventoryLine : IMergePatchPhysicalInventoryLine, new() { bool bUnsaved = ((IPhysicalInventoryState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreatePhysicalInventory <TCreatePhysicalInventory, TCreatePhysicalInventoryLine>()); } else { return(state.ToMergePatchPhysicalInventory <TMergePatchPhysicalInventory, TCreatePhysicalInventoryLine, TMergePatchPhysicalInventoryLine>()); } }
public static TCreatePhysicalInventory ToCreatePhysicalInventory <TCreatePhysicalInventory, TCreatePhysicalInventoryLine>(this IPhysicalInventoryState state) where TCreatePhysicalInventory : ICreatePhysicalInventory, new() where TCreatePhysicalInventoryLine : ICreatePhysicalInventoryLine, new() { var cmd = new TCreatePhysicalInventory(); cmd.Version = ((IPhysicalInventoryStateProperties)state).Version; cmd.DocumentNumber = state.DocumentNumber; cmd.WarehouseId = state.WarehouseId; cmd.LocatorIdPattern = state.LocatorIdPattern; cmd.ProductIdPattern = state.ProductIdPattern; cmd.Posted = state.Posted; cmd.Processed = state.Processed; cmd.Processing = state.Processing; cmd.DocumentTypeId = state.DocumentTypeId; cmd.MovementDate = state.MovementDate; cmd.Description = state.Description; cmd.IsApproved = state.IsApproved; cmd.ApprovalAmount = state.ApprovalAmount; cmd.IsQuantityUpdated = state.IsQuantityUpdated; cmd.ReversalDocumentNumber = state.ReversalDocumentNumber; cmd.Active = ((IPhysicalInventoryStateProperties)state).Active; foreach (var d in state.PhysicalInventoryLines) { var c = d.ToCreatePhysicalInventoryLine <TCreatePhysicalInventoryLine>(); cmd.PhysicalInventoryLines.Add(c); } return(cmd); }
public PhysicalInventoryAggregate(IPhysicalInventoryState state) { _state = state; }
protected void NewPhysicalInventoryDocumentActionCommandAndExecute(ICreatePhysicalInventory c, IPhysicalInventoryState s, IPhysicalInventoryStateCreated e) { var pCommandHandler = this.PhysicalInventoryDocumentActionCommandHandler; var pCmdContent = default(string); var pCmd = new PropertyCommand <string, string> { Content = pCmdContent, GetState = () => s.DocumentStatusId, SetState = p => e.DocumentStatusId = p, OuterCommandType = CommandType.Create }; pCmd.Context = this.State; pCommandHandler.Execute(pCmd); }
}// END Map(ICreate... //////////////////////////// protected virtual IPhysicalInventoryLineStateMergePatched MapMergePatch(IMergePatchPhysicalInventoryLine c, IPhysicalInventoryCommand outerCommand, long version, IPhysicalInventoryState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new PhysicalInventoryLineEventId(c.PhysicalInventoryDocumentNumber, c.InventoryItemId, version); IPhysicalInventoryLineStateMergePatched e = NewPhysicalInventoryLineStateMergePatched(stateEventId); var s = outerState.PhysicalInventoryLines.Get(c.InventoryItemId); e.BookQuantity = c.BookQuantity; e.CountedQuantity = c.CountedQuantity; e.Processed = c.Processed; e.LineNumber = c.LineNumber; e.ReversalLineNumber = c.ReversalLineNumber; e.Description = c.Description; e.IsPropertyBookQuantityRemoved = c.IsPropertyBookQuantityRemoved; e.IsPropertyCountedQuantityRemoved = c.IsPropertyCountedQuantityRemoved; e.IsPropertyProcessedRemoved = c.IsPropertyProcessedRemoved; e.IsPropertyLineNumberRemoved = c.IsPropertyLineNumberRemoved; e.IsPropertyReversalLineNumberRemoved = c.IsPropertyReversalLineNumberRemoved; e.IsPropertyDescriptionRemoved = c.IsPropertyDescriptionRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IPhysicalInventoryLineEvent Map(IPhysicalInventoryLineCommand c, IPhysicalInventoryCommand outerCommand, long version, IPhysicalInventoryState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreatePhysicalInventoryLine) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchPhysicalInventoryLine) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemovePhysicalInventoryLine) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
public PhysicalInventoryStateDtoWrapper() { this._state = new PhysicalInventoryState(); }
public PhysicalInventoryStateDtoWrapper(IPhysicalInventoryState state) { this._state = state; }
public static TDeletePhysicalInventory ToDeletePhysicalInventory <TDeletePhysicalInventory>(this IPhysicalInventoryState state) where TDeletePhysicalInventory : IDeletePhysicalInventory, new() { var cmd = new TDeletePhysicalInventory(); cmd.DocumentNumber = state.DocumentNumber; cmd.Version = ((IPhysicalInventoryStateProperties)state).Version; return(cmd); }
public override IPhysicalInventoryAggregate GetPhysicalInventoryAggregate(IPhysicalInventoryState state) { return(new PhysicalInventoryAggregate(state)); }
public static TMergePatchPhysicalInventory ToMergePatchPhysicalInventory <TMergePatchPhysicalInventory, TCreatePhysicalInventoryLine, TMergePatchPhysicalInventoryLine>(this IPhysicalInventoryState state) where TMergePatchPhysicalInventory : IMergePatchPhysicalInventory, new() where TCreatePhysicalInventoryLine : ICreatePhysicalInventoryLine, new() where TMergePatchPhysicalInventoryLine : IMergePatchPhysicalInventoryLine, new() { var cmd = new TMergePatchPhysicalInventory(); cmd.Version = ((IPhysicalInventoryStateProperties)state).Version; cmd.DocumentNumber = state.DocumentNumber; cmd.WarehouseId = state.WarehouseId; cmd.LocatorIdPattern = state.LocatorIdPattern; cmd.ProductIdPattern = state.ProductIdPattern; cmd.Posted = state.Posted; cmd.Processed = state.Processed; cmd.Processing = state.Processing; cmd.DocumentTypeId = state.DocumentTypeId; cmd.MovementDate = state.MovementDate; cmd.Description = state.Description; cmd.IsApproved = state.IsApproved; cmd.ApprovalAmount = state.ApprovalAmount; cmd.IsQuantityUpdated = state.IsQuantityUpdated; cmd.ReversalDocumentNumber = state.ReversalDocumentNumber; cmd.Active = ((IPhysicalInventoryStateProperties)state).Active; if (state.WarehouseId == null) { cmd.IsPropertyWarehouseIdRemoved = true; } if (state.LocatorIdPattern == null) { cmd.IsPropertyLocatorIdPatternRemoved = true; } if (state.ProductIdPattern == null) { cmd.IsPropertyProductIdPatternRemoved = true; } if (state.Processing == null) { cmd.IsPropertyProcessingRemoved = true; } if (state.DocumentTypeId == null) { cmd.IsPropertyDocumentTypeIdRemoved = true; } if (state.MovementDate == null) { cmd.IsPropertyMovementDateRemoved = true; } if (state.Description == null) { cmd.IsPropertyDescriptionRemoved = true; } if (state.ReversalDocumentNumber == null) { cmd.IsPropertyReversalDocumentNumberRemoved = true; } foreach (var d in state.PhysicalInventoryLines) { var c = d.ToCreateOrMergePatchPhysicalInventoryLine <TCreatePhysicalInventoryLine, TMergePatchPhysicalInventoryLine>(); cmd.PhysicalInventoryLineCommands.Add(c); } return(cmd); }