示例#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);
        }