예제 #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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 private void AddMovementConfirmationLines(IMovementState movement, ICreateMovementConfirmation movConfirm)
 {
     foreach (var movLine in movement.MovementLines)
     {
         var confirmLine = new CreateMovementConfirmationLine();
         //confirmLine.MovementConfirmationDocumentNumber = movConfirm;
         //confirmLine.CreatedBy = confirmLine.UpdatedBy = Context.User;
         //confirmLine.CreationTime = confirmLine.UpdateTime = now;
         confirmLine.LineNumber         = movLine.LineNumber;//SeqIdGenerator.GetNextId().ToString();
         confirmLine.MovementLineNumber = movLine.LineNumber;
         confirmLine.TargetQuantity     = movLine.MovementQuantity;
         confirmLine.ConfirmedQuantity  = 0L; //??
         movConfirm.MovementConfirmationLines.Add(confirmLine);
     }
 }
예제 #4
0
        public virtual void Create(ICreateMovementConfirmation c)
        {
            IMovementConfirmationStateCreated e = Map(c);

            Apply(e);
        }
 void IMovementConfirmationApplicationService.When(ICreateMovementConfirmation c)
 {
     this.When((CreateMovementConfirmationDto)c);
 }
예제 #6
0
 public virtual void When(ICreateMovementConfirmation c)
 {
     Update(c, ar => ar.Create(c));
 }