Example #1
0
        protected virtual IMovementStateCreated Map(ICreateMovement c)
        {
            var stateEventId        = new MovementEventId(c.DocumentNumber, c.Version);
            IMovementStateCreated e = NewMovementStateCreated(stateEventId);

            NewMovementDocumentActionCommandAndExecute(c, _state, e);
            e.MovementDate           = c.MovementDate;
            e.Posted                 = c.Posted;
            e.Processed              = c.Processed;
            e.Processing             = c.Processing;
            e.DateReceived           = c.DateReceived;
            e.DocumentTypeId         = c.DocumentTypeId;
            e.IsInTransit            = c.IsInTransit;
            e.IsApproved             = c.IsApproved;
            e.ApprovalAmount         = c.ApprovalAmount;
            e.ShipperId              = c.ShipperId;
            e.SalesRepresentativeId  = c.SalesRepresentativeId;
            e.BusinessPartnerId      = c.BusinessPartnerId;
            e.ChargeAmount           = c.ChargeAmount;
            e.CreateFrom             = c.CreateFrom;
            e.FreightAmount          = c.FreightAmount;
            e.ReversalDocumentNumber = c.ReversalDocumentNumber;
            e.WarehouseIdFrom        = c.WarehouseIdFrom;
            e.WarehouseIdTo          = c.WarehouseIdTo;
            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 (ICreateMovementLine innerCommand in c.MovementLines)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IMovementLineStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddMovementLineEvent(innerEvent);
            }


            return(e);
        }
        public virtual MovementLineStateCreatedDto ToMovementLineStateCreatedDto(IMovementLineStateCreated e)
        {
            var dto = new MovementLineStateCreatedDto();

            dto.MovementLineEventId    = e.MovementLineEventId;
            dto.CreatedAt              = e.CreatedAt;
            dto.CreatedBy              = e.CreatedBy;
            dto.Version                = e.Version;
            dto.CommandId              = e.CommandId;
            dto.MovementQuantity       = e.MovementQuantity;
            dto.ProductId              = e.ProductId;
            dto.LocatorIdFrom          = e.LocatorIdFrom;
            dto.LocatorIdTo            = e.LocatorIdTo;
            dto.AttributeSetInstanceId = e.AttributeSetInstanceId;
            dto.Processed              = e.Processed;
            dto.ReversalLineNumber     = e.ReversalLineNumber;
            dto.Active = e.Active;
            return(dto);
        }
Example #3
0
        protected virtual IMovementLineStateCreated MapCreate(ICreateMovementLine c, IMovementCommand outerCommand, long version, IMovementState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId            = new MovementLineEventId(c.MovementDocumentNumber, c.LineNumber, version);
            IMovementLineStateCreated e = NewMovementLineStateCreated(stateEventId);
            var s = outerState.MovementLines.Get(c.LineNumber, true);

            e.MovementQuantity       = c.MovementQuantity;
            e.ProductId              = c.ProductId;
            e.LocatorIdFrom          = c.LocatorIdFrom;
            e.LocatorIdTo            = c.LocatorIdTo;
            e.AttributeSetInstanceId = c.AttributeSetInstanceId;
            e.Processed              = c.Processed;
            e.ReversalLineNumber     = c.ReversalLineNumber;
            e.Active = c.Active;

            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            return(e);
        }// END Map(ICreate... ////////////////////////////
Example #4
0
        public virtual void When(IMovementLineStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.MovementQuantity = (e.MovementQuantity != null && e.MovementQuantity.HasValue) ? e.MovementQuantity.Value : default(decimal);

            this.ProductId = e.ProductId;

            this.LocatorIdFrom = e.LocatorIdFrom;

            this.LocatorIdTo = e.LocatorIdTo;

            this.AttributeSetInstanceId = e.AttributeSetInstanceId;

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

            this.ReversalLineNumber = e.ReversalLineNumber;

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Example #5
0
 public virtual void AddMovementLineEvent(IMovementLineStateCreated e)
 {
     ThrowOnInconsistentEventIds(e);
     this._movementLineEvents[e.MovementLineEventId] = e;
 }
 void IMovementLineState.When(IMovementLineStateCreated e)
 {
     throw new NotSupportedException();
 }
Example #7
0
 void IMovementStateCreated.AddMovementLineEvent(IMovementLineStateCreated e)
 {
     this._movementLineEvents.AddMovementLineEvent(e);
 }