Пример #1
0
        public virtual void When(IMovementConfirmationStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.DocumentStatusId = e.DocumentStatusId;

            this.MovementDocumentNumber = e.MovementDocumentNumber;

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

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

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

            this.Processing = e.Processing;

            this.DocumentTypeId = e.DocumentTypeId;

            this.Description = e.Description;

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;

            foreach (IMovementConfirmationLineStateCreated innerEvent in e.MovementConfirmationLineEvents)
            {
                IMovementConfirmationLineState innerState = this.MovementConfirmationLines.Get(innerEvent.GlobalId.LineNumber, true);
                innerState.Mutate(innerEvent);
            }
        }
Пример #2
0
        public IMovementConfirmationLineState Get(MovementConfirmationLineId id, bool nullAllowed)
        {
            IMovementConfirmationLineState state = CurrentSession.Get <MovementConfirmationLineState>(id);

            if (!nullAllowed && state == null)
            {
                state = new MovementConfirmationLineState();
                (state as MovementConfirmationLineState).MovementConfirmationLineId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IMovementConfirmationLineState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Пример #3
0
        public void Delete(IMovementConfirmationLineState state)
        {
            IMovementConfirmationLineState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IMovementConfirmationLineState>(state);
            }
            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Delete(s);
        }
Пример #4
0
 public MovementConfirmationLineStateDtoWrapper(IMovementConfirmationLineState state)
 {
     this._state = state;
 }
Пример #5
0
 public MovementConfirmationLineStateDtoWrapper()
 {
     this._state = new MovementConfirmationLineState();
 }
Пример #6
0
 public virtual void Remove(IMovementConfirmationLineState state)
 {
     this._removedMovementConfirmationLineStates.Add(state.GlobalId, state);
 }
Пример #7
0
 public virtual void AddToSave(IMovementConfirmationLineState state)
 {
     this._loadedMovementConfirmationLineStates[state.GlobalId] = state;
 }
Пример #8
0
        public static TCreateMovementConfirmationLine ToCreateMovementConfirmationLine <TCreateMovementConfirmationLine>(this IMovementConfirmationLineState state)
            where TCreateMovementConfirmationLine : ICreateMovementConfirmationLine, new()
        {
            var cmd = new TCreateMovementConfirmationLine();

            cmd.LineNumber         = state.LineNumber;
            cmd.MovementLineNumber = state.MovementLineNumber;
            cmd.TargetQuantity     = state.TargetQuantity;
            cmd.ConfirmedQuantity  = state.ConfirmedQuantity;
            cmd.DifferenceQuantity = state.DifferenceQuantity;
            cmd.ScrappedQuantity   = state.ScrappedQuantity;
            cmd.Description        = state.Description;
            cmd.Processed          = state.Processed;
            cmd.Active             = ((IMovementConfirmationLineStateProperties)state).Active;
            cmd.MovementConfirmationDocumentNumber = state.MovementConfirmationDocumentNumber;
            return(cmd);
        }
Пример #9
0
        public static TMergePatchMovementConfirmationLine ToMergePatchMovementConfirmationLine <TMergePatchMovementConfirmationLine>(this IMovementConfirmationLineState state)
            where TMergePatchMovementConfirmationLine : IMergePatchMovementConfirmationLine, new()
        {
            var cmd = new TMergePatchMovementConfirmationLine();

            cmd.LineNumber         = state.LineNumber;
            cmd.MovementLineNumber = state.MovementLineNumber;
            cmd.TargetQuantity     = state.TargetQuantity;
            cmd.ConfirmedQuantity  = state.ConfirmedQuantity;
            cmd.DifferenceQuantity = state.DifferenceQuantity;
            cmd.ScrappedQuantity   = state.ScrappedQuantity;
            cmd.Description        = state.Description;
            cmd.Processed          = state.Processed;
            cmd.Active             = ((IMovementConfirmationLineStateProperties)state).Active;
            cmd.MovementConfirmationDocumentNumber = state.MovementConfirmationDocumentNumber;

            if (state.MovementLineNumber == null)
            {
                cmd.IsPropertyMovementLineNumberRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
Пример #10
0
        public static TRemoveMovementConfirmationLine ToRemoveMovementConfirmationLine <TRemoveMovementConfirmationLine>(this IMovementConfirmationLineState state)
            where TRemoveMovementConfirmationLine : IRemoveMovementConfirmationLine, new()
        {
            var cmd = new TRemoveMovementConfirmationLine();

            cmd.LineNumber = state.LineNumber;
            return(cmd);
        }
Пример #11
0
        public static IMovementConfirmationLineCommand ToCreateOrMergePatchMovementConfirmationLine <TCreateMovementConfirmationLine, TMergePatchMovementConfirmationLine>(this IMovementConfirmationLineState state)
            where TCreateMovementConfirmationLine : ICreateMovementConfirmationLine, new()
            where TMergePatchMovementConfirmationLine : IMergePatchMovementConfirmationLine, new()
        {
            bool bUnsaved = ((IMovementConfirmationLineState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateMovementConfirmationLine <TCreateMovementConfirmationLine>());
            }
            else
            {
                return(state.ToMergePatchMovementConfirmationLine <TMergePatchMovementConfirmationLine>());
            }
        }
 public void AddToSave(IMovementConfirmationLineState state)
 {
     throw new NotSupportedException();
 }
Пример #13
0
        public virtual void When(IMovementConfirmationStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.DocumentStatusId == null)
            {
                if (e.IsPropertyDocumentStatusIdRemoved)
                {
                    this.DocumentStatusId = default(string);
                }
            }
            else
            {
                this.DocumentStatusId = e.DocumentStatusId;
            }

            if (e.MovementDocumentNumber == null)
            {
                if (e.IsPropertyMovementDocumentNumberRemoved)
                {
                    this.MovementDocumentNumber = default(string);
                }
            }
            else
            {
                this.MovementDocumentNumber = e.MovementDocumentNumber;
            }

            if (e.IsApproved == null)
            {
                if (e.IsPropertyIsApprovedRemoved)
                {
                    this.IsApproved = default(bool);
                }
            }
            else
            {
                this.IsApproved = (e.IsApproved != null && e.IsApproved.HasValue) ? e.IsApproved.Value : default(bool);
            }

            if (e.ApprovalAmount == null)
            {
                if (e.IsPropertyApprovalAmountRemoved)
                {
                    this.ApprovalAmount = default(decimal);
                }
            }
            else
            {
                this.ApprovalAmount = (e.ApprovalAmount != null && e.ApprovalAmount.HasValue) ? e.ApprovalAmount.Value : default(decimal);
            }

            if (e.Processed == null)
            {
                if (e.IsPropertyProcessedRemoved)
                {
                    this.Processed = default(bool);
                }
            }
            else
            {
                this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool);
            }

            if (e.Processing == null)
            {
                if (e.IsPropertyProcessingRemoved)
                {
                    this.Processing = default(string);
                }
            }
            else
            {
                this.Processing = e.Processing;
            }

            if (e.DocumentTypeId == null)
            {
                if (e.IsPropertyDocumentTypeIdRemoved)
                {
                    this.DocumentTypeId = default(string);
                }
            }
            else
            {
                this.DocumentTypeId = e.DocumentTypeId;
            }

            if (e.Description == null)
            {
                if (e.IsPropertyDescriptionRemoved)
                {
                    this.Description = default(string);
                }
            }
            else
            {
                this.Description = e.Description;
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IMovementConfirmationLineEvent innerEvent in e.MovementConfirmationLineEvents)
            {
                IMovementConfirmationLineState innerState = this.MovementConfirmationLines.Get(innerEvent.GlobalId.LineNumber);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IMovementConfirmationLineStateRemoved;
                if (removed != null)
                {
                    this.MovementConfirmationLines.Remove(innerState);
                }
            }
        }