public IMovementConfirmationState Get(string id) { IMovementConfirmationState state = CurrentSession.Get <MovementConfirmationState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementConfirmationState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public DtoMovementConfirmationLineStates(IMovementConfirmationState outerState, IEnumerable <IMovementConfirmationLineState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IMovementConfirmationLineState[] { }; } else { this._innerStates = innerStates; } }
public IMovementConfirmationState Get(string id, bool nullAllowed) { IMovementConfirmationState state = CurrentSession.Get <MovementConfirmationState> (id); if (!nullAllowed && state == null) { state = new MovementConfirmationState(); (state as MovementConfirmationState).DocumentNumber = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementConfirmationState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IMovementConfirmationState> GetAsync(string documentNumber) { IMovementConfirmationState state = null; var idObj = documentNumber; var uriParameters = new MovementConfirmationUriParameters(); uriParameters.Id = idObj; var req = new MovementConfirmationGetRequest(uriParameters); var resp = await _ramlClient.MovementConfirmation.Get(req); MovementConfirmationProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToMovementConfirmationState(); return(state); }
public void Save(IMovementConfirmationState state) { IMovementConfirmationState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IMovementConfirmationState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IMovementConfirmationAggregate aggregate, IMovementConfirmationState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IMovementConfirmationStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IMovementConfirmationAggregate, IMovementConfirmationState>(aggregate, state, aggregate.Changes)); } }
public static TCreateMovementConfirmation ToCreateMovementConfirmation <TCreateMovementConfirmation, TCreateMovementConfirmationLine>(this IMovementConfirmationState state) where TCreateMovementConfirmation : ICreateMovementConfirmation, new() where TCreateMovementConfirmationLine : ICreateMovementConfirmationLine, new() { var cmd = new TCreateMovementConfirmation(); cmd.Version = ((IMovementConfirmationStateProperties)state).Version; cmd.DocumentNumber = state.DocumentNumber; cmd.MovementDocumentNumber = state.MovementDocumentNumber; cmd.IsApproved = state.IsApproved; cmd.ApprovalAmount = state.ApprovalAmount; cmd.Processed = state.Processed; cmd.Processing = state.Processing; cmd.DocumentTypeId = state.DocumentTypeId; cmd.Description = state.Description; cmd.Active = ((IMovementConfirmationStateProperties)state).Active; foreach (var d in state.MovementConfirmationLines) { var c = d.ToCreateMovementConfirmationLine <TCreateMovementConfirmationLine>(); cmd.MovementConfirmationLines.Add(c); } return(cmd); }
public static TDeleteMovementConfirmation ToDeleteMovementConfirmation <TDeleteMovementConfirmation>(this IMovementConfirmationState state) where TDeleteMovementConfirmation : IDeleteMovementConfirmation, new() { var cmd = new TDeleteMovementConfirmation(); cmd.DocumentNumber = state.DocumentNumber; cmd.Version = ((IMovementConfirmationStateProperties)state).Version; return(cmd); }
protected void NewMovementConfirmationDocumentActionCommandAndExecute(ICreateMovementConfirmation c, IMovementConfirmationState s, IMovementConfirmationStateCreated e) { var pCommandHandler = this.MovementConfirmationDocumentActionCommandHandler; 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 IMovementConfirmationLineStateMergePatched MapMergePatch(IMergePatchMovementConfirmationLine c, IMovementConfirmationCommand outerCommand, long version, IMovementConfirmationState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new MovementConfirmationLineEventId(c.MovementConfirmationDocumentNumber, c.LineNumber, version); IMovementConfirmationLineStateMergePatched e = NewMovementConfirmationLineStateMergePatched(stateEventId); var s = outerState.MovementConfirmationLines.Get(c.LineNumber); e.MovementLineNumber = c.MovementLineNumber; e.TargetQuantity = c.TargetQuantity; e.ConfirmedQuantity = c.ConfirmedQuantity; e.DifferenceQuantity = c.DifferenceQuantity; e.ScrappedQuantity = c.ScrappedQuantity; e.Description = c.Description; e.Processed = c.Processed; e.Active = c.Active; e.IsPropertyMovementLineNumberRemoved = c.IsPropertyMovementLineNumberRemoved; e.IsPropertyTargetQuantityRemoved = c.IsPropertyTargetQuantityRemoved; e.IsPropertyConfirmedQuantityRemoved = c.IsPropertyConfirmedQuantityRemoved; e.IsPropertyDifferenceQuantityRemoved = c.IsPropertyDifferenceQuantityRemoved; e.IsPropertyScrappedQuantityRemoved = c.IsPropertyScrappedQuantityRemoved; e.IsPropertyDescriptionRemoved = c.IsPropertyDescriptionRemoved; e.IsPropertyProcessedRemoved = c.IsPropertyProcessedRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IMovementConfirmationLineEvent Map(IMovementConfirmationLineCommand c, IMovementConfirmationCommand outerCommand, long version, IMovementConfirmationState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateMovementConfirmationLine) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchMovementConfirmationLine) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemoveMovementConfirmationLine) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
private static IDictionary <string, Tuple <decimal, decimal, decimal> > GetQuantitiesDictionary(IMovementConfirmationState movConfirm) { var quantitiesDict = movConfirm.MovementConfirmationLines.ToDictionary( d => d.MovementLineNumber, d => new Tuple <decimal, decimal, decimal>(d.TargetQuantity, d.ConfirmedQuantity, d.ScrappedQuantity)); foreach (var e in quantitiesDict) { var b = e.Value.Item1 == e.Value.Item2 + e.Value.Item3; if (!b) { throw new ApplicationException(String.Format("Error movement confirmation line quantities. Movement line No.: {0}", e.Key)); } } return(quantitiesDict); }
protected bool IsRepeatedCommand(IMovementConfirmationCommand command, IEventStoreAggregateId eventStoreAggregateId, IMovementConfirmationState state) { bool repeated = false; if (((IMovementConfirmationStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IMovementConfirmationEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
public MovementConfirmationLineStates(IMovementConfirmationState outerState) { this._movementConfirmationState = outerState; this._forReapplying = outerState.ForReapplying; }
public MovementConfirmationAggregate(IMovementConfirmationState state) { _state = state; }
public static IMovementConfirmationCommand ToCreateOrMergePatchMovementConfirmation <TCreateMovementConfirmation, TMergePatchMovementConfirmation, TCreateMovementConfirmationLine, TMergePatchMovementConfirmationLine>(this IMovementConfirmationState state) where TCreateMovementConfirmation : ICreateMovementConfirmation, new() where TMergePatchMovementConfirmation : IMergePatchMovementConfirmation, new() where TCreateMovementConfirmationLine : ICreateMovementConfirmationLine, new() where TMergePatchMovementConfirmationLine : IMergePatchMovementConfirmationLine, new() { bool bUnsaved = ((IMovementConfirmationState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateMovementConfirmation <TCreateMovementConfirmation, TCreateMovementConfirmationLine>()); } else { return(state.ToMergePatchMovementConfirmation <TMergePatchMovementConfirmation, TCreateMovementConfirmationLine, TMergePatchMovementConfirmationLine>()); } }
public MovementConfirmationStateDtoWrapper() { this._state = new MovementConfirmationState(); }
public static TMergePatchMovementConfirmation ToMergePatchMovementConfirmation <TMergePatchMovementConfirmation, TCreateMovementConfirmationLine, TMergePatchMovementConfirmationLine>(this IMovementConfirmationState state) where TMergePatchMovementConfirmation : IMergePatchMovementConfirmation, new() where TCreateMovementConfirmationLine : ICreateMovementConfirmationLine, new() where TMergePatchMovementConfirmationLine : IMergePatchMovementConfirmationLine, new() { var cmd = new TMergePatchMovementConfirmation(); cmd.Version = ((IMovementConfirmationStateProperties)state).Version; cmd.DocumentNumber = state.DocumentNumber; cmd.MovementDocumentNumber = state.MovementDocumentNumber; cmd.IsApproved = state.IsApproved; cmd.ApprovalAmount = state.ApprovalAmount; cmd.Processed = state.Processed; cmd.Processing = state.Processing; cmd.DocumentTypeId = state.DocumentTypeId; cmd.Description = state.Description; cmd.Active = ((IMovementConfirmationStateProperties)state).Active; if (state.MovementDocumentNumber == null) { cmd.IsPropertyMovementDocumentNumberRemoved = true; } if (state.Processing == null) { cmd.IsPropertyProcessingRemoved = true; } if (state.DocumentTypeId == null) { cmd.IsPropertyDocumentTypeIdRemoved = true; } if (state.Description == null) { cmd.IsPropertyDescriptionRemoved = true; } foreach (var d in state.MovementConfirmationLines) { var c = d.ToCreateOrMergePatchMovementConfirmationLine <TCreateMovementConfirmationLine, TMergePatchMovementConfirmationLine>(); cmd.MovementConfirmationLineCommands.Add(c); } return(cmd); }
public MovementConfirmationStateDtoWrapper(IMovementConfirmationState state) { this._state = state; }
public override IMovementConfirmationAggregate GetMovementConfirmationAggregate(IMovementConfirmationState state) { return(new MovementConfirmationAggregate(state)); }
public abstract IMovementConfirmationAggregate GetMovementConfirmationAggregate(IMovementConfirmationState state);