Exemple #1
0
        public virtual void Initialize(IMovementConfirmationStateCreated stateCreated)
        {
            var aggregateId = stateCreated.MovementConfirmationEventId.DocumentNumber;
            var state       = new MovementConfirmationState();

            state.DocumentNumber = aggregateId;
            var aggregate = (MovementConfirmationAggregate)GetMovementConfirmationAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
        public virtual IMovementConfirmationState ToMovementConfirmationState()
        {
            var state = new MovementConfirmationState(true);

            state.DocumentNumber         = this.DocumentNumber;
            state.DocumentStatusId       = this.DocumentStatusId;
            state.MovementDocumentNumber = this.MovementDocumentNumber;
            if (this.IsApproved != null && this.IsApproved.HasValue)
            {
                state.IsApproved = this.IsApproved.Value;
            }
            if (this.ApprovalAmount != null && this.ApprovalAmount.HasValue)
            {
                state.ApprovalAmount = this.ApprovalAmount.Value;
            }
            if (this.Processed != null && this.Processed.HasValue)
            {
                state.Processed = this.Processed.Value;
            }
            state.Processing     = this.Processing;
            state.DocumentTypeId = this.DocumentTypeId;
            state.Description    = this.Description;
            if (this.Active != null && this.Active.HasValue)
            {
                state.Active = this.Active.Value;
            }
            if (this.Version != null && this.Version.HasValue)
            {
                state.Version = this.Version.Value;
            }
            state.CreatedBy = this.CreatedBy;
            if (this.CreatedAt != null && this.CreatedAt.HasValue)
            {
                state.CreatedAt = this.CreatedAt.Value;
            }
            state.UpdatedBy = this.UpdatedBy;
            if (this.UpdatedAt != null && this.UpdatedAt.HasValue)
            {
                state.UpdatedAt = this.UpdatedAt.Value;
            }
            if (this.MovementConfirmationLines != null)
            {
                foreach (var s in this.MovementConfirmationLines)
                {
                    state.MovementConfirmationLines.AddToSave(s.ToMovementConfirmationLineState());
                }
            }
            ;

            return(state);
        }
 public static CreateMovementConfirmation ToCreateMovementConfirmation(this MovementConfirmationState state)
 {
     return(state.ToCreateMovementConfirmation <CreateMovementConfirmation, CreateMovementConfirmationLine>());
 }
 public static MergePatchMovementConfirmation ToMergePatchMovementConfirmation(this MovementConfirmationState state)
 {
     return(state.ToMergePatchMovementConfirmation <MergePatchMovementConfirmation, CreateMovementConfirmationLine, MergePatchMovementConfirmationLine>());
 }
 public static DeleteMovementConfirmation ToDeleteMovementConfirmation(this MovementConfirmationState state)
 {
     return(state.ToDeleteMovementConfirmation <DeleteMovementConfirmation>());
 }
 public static IMovementConfirmationCommand ToCreateOrMergePatchMovementConfirmation(this MovementConfirmationState state)
 {
     return(state.ToCreateOrMergePatchMovementConfirmation <CreateMovementConfirmation, MergePatchMovementConfirmation, CreateMovementConfirmationLine, MergePatchMovementConfirmationLine>());
 }