Esempio n. 1
0
        protected virtual IMovementConfirmationStateCreated Map(ICreateMovementConfirmation c)
        {
            var stateEventId = new MovementConfirmationEventId(c.DocumentNumber, c.Version);
            IMovementConfirmationStateCreated e = NewMovementConfirmationStateCreated(stateEventId);

            NewMovementConfirmationDocumentActionCommandAndExecute(c, _state, e);
            e.MovementDocumentNumber = c.MovementDocumentNumber;
            e.IsApproved             = c.IsApproved;
            e.ApprovalAmount         = c.ApprovalAmount;
            e.Processed      = c.Processed;
            e.Processing     = c.Processing;
            e.DocumentTypeId = c.DocumentTypeId;
            e.Description    = c.Description;
            e.Active         = c.Active;
            e.CommandId      = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            var version = c.Version;

            foreach (ICreateMovementConfirmationLine innerCommand in c.MovementConfirmationLines)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IMovementConfirmationLineStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddMovementConfirmationLineEvent(innerEvent);
            }


            return(e);
        }
Esempio n. 2
0
        protected virtual IMovementConfirmationLineStateCreated MapCreate(ICreateMovementConfirmationLine c, IMovementConfirmationCommand outerCommand, long version, IMovementConfirmationState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId = new MovementConfirmationLineEventId(c.MovementConfirmationDocumentNumber, c.LineNumber, version);
            IMovementConfirmationLineStateCreated e = NewMovementConfirmationLineStateCreated(stateEventId);
            var s = outerState.MovementConfirmationLines.Get(c.LineNumber, true);

            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.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            return(e);
        }// END Map(ICreate... ////////////////////////////
Esempio n. 3
0
        public virtual void When(IMovementConfirmationLineStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.MovementLineNumber = e.MovementLineNumber;

            this.TargetQuantity = (e.TargetQuantity != null && e.TargetQuantity.HasValue) ? e.TargetQuantity.Value : default(decimal);

            this.ConfirmedQuantity = (e.ConfirmedQuantity != null && e.ConfirmedQuantity.HasValue) ? e.ConfirmedQuantity.Value : default(decimal);

            this.DifferenceQuantity = (e.DifferenceQuantity != null && e.DifferenceQuantity.HasValue) ? e.DifferenceQuantity.Value : default(decimal);

            this.ScrappedQuantity = (e.ScrappedQuantity != null && e.ScrappedQuantity.HasValue) ? e.ScrappedQuantity.Value : default(decimal);

            this.Description = e.Description;

            this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool);

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Esempio n. 4
0
 public virtual void AddMovementConfirmationLineEvent(IMovementConfirmationLineStateCreated e)
 {
     ThrowOnInconsistentEventIds(e);
     this._movementConfirmationLineEvents[e.MovementConfirmationLineEventId] = e;
 }
        public virtual MovementConfirmationLineStateCreatedDto ToMovementConfirmationLineStateCreatedDto(IMovementConfirmationLineStateCreated e)
        {
            var dto = new MovementConfirmationLineStateCreatedDto();

            dto.MovementConfirmationLineEventId = e.MovementConfirmationLineEventId;
            dto.CreatedAt          = e.CreatedAt;
            dto.CreatedBy          = e.CreatedBy;
            dto.Version            = e.Version;
            dto.CommandId          = e.CommandId;
            dto.MovementLineNumber = e.MovementLineNumber;
            dto.TargetQuantity     = e.TargetQuantity;
            dto.ConfirmedQuantity  = e.ConfirmedQuantity;
            dto.DifferenceQuantity = e.DifferenceQuantity;
            dto.ScrappedQuantity   = e.ScrappedQuantity;
            dto.Description        = e.Description;
            dto.Processed          = e.Processed;
            dto.Active             = e.Active;
            return(dto);
        }
Esempio n. 6
0
 void IMovementConfirmationLineState.When(IMovementConfirmationLineStateCreated e)
 {
     throw new NotSupportedException();
 }
 void IMovementConfirmationStateCreated.AddMovementConfirmationLineEvent(IMovementConfirmationLineStateCreated e)
 {
     this._movementConfirmationLineEvents.AddMovementConfirmationLineEvent(e);
 }