public IPhysicalInventoryLineState Get(PhysicalInventoryLineId id, bool nullAllowed)
        {
            IPhysicalInventoryLineState state = CurrentSession.Get <PhysicalInventoryLineState>(id);

            if (!nullAllowed && state == null)
            {
                state = new PhysicalInventoryLineState();
                (state as PhysicalInventoryLineState).PhysicalInventoryLineId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPhysicalInventoryLineState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public void Delete(IPhysicalInventoryLineState state)
        {
            IPhysicalInventoryLineState s = state;

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

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Delete(s);
        }
Exemplo n.º 3
0
        public virtual void When(IPhysicalInventoryStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.DocumentStatusId = e.DocumentStatusId;

            this.WarehouseId = e.WarehouseId;

            this.LocatorIdPattern = e.LocatorIdPattern;

            this.ProductIdPattern = e.ProductIdPattern;

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

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

            this.Processing = e.Processing;

            this.DocumentTypeId = e.DocumentTypeId;

            this.MovementDate = e.MovementDate;

            this.Description = e.Description;

            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.IsQuantityUpdated = (e.IsQuantityUpdated != null && e.IsQuantityUpdated.HasValue) ? e.IsQuantityUpdated.Value : default(bool);

            this.ReversalDocumentNumber = e.ReversalDocumentNumber;

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

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

            foreach (IPhysicalInventoryLineStateCreated innerEvent in e.PhysicalInventoryLineEvents)
            {
                IPhysicalInventoryLineState innerState = this.PhysicalInventoryLines.Get(innerEvent.GlobalId.InventoryItemId, true);
                innerState.Mutate(innerEvent);
            }
        }
Exemplo n.º 4
0
 public PhysicalInventoryLineStateDtoWrapper(IPhysicalInventoryLineState state)
 {
     this._state = state;
 }
Exemplo n.º 5
0
 public PhysicalInventoryLineStateDtoWrapper()
 {
     this._state = new PhysicalInventoryLineState();
 }
Exemplo n.º 6
0
        public static TCreatePhysicalInventoryLine ToCreatePhysicalInventoryLine <TCreatePhysicalInventoryLine>(this IPhysicalInventoryLineState state)
            where TCreatePhysicalInventoryLine : ICreatePhysicalInventoryLine, new()
        {
            var cmd = new TCreatePhysicalInventoryLine();

            cmd.InventoryItemId    = state.InventoryItemId;
            cmd.BookQuantity       = state.BookQuantity;
            cmd.CountedQuantity    = state.CountedQuantity;
            cmd.Processed          = state.Processed;
            cmd.LineNumber         = state.LineNumber;
            cmd.ReversalLineNumber = state.ReversalLineNumber;
            cmd.Description        = state.Description;
            cmd.PhysicalInventoryDocumentNumber = state.PhysicalInventoryDocumentNumber;
            return(cmd);
        }
Exemplo n.º 7
0
        public static TMergePatchPhysicalInventoryLine ToMergePatchPhysicalInventoryLine <TMergePatchPhysicalInventoryLine>(this IPhysicalInventoryLineState state)
            where TMergePatchPhysicalInventoryLine : IMergePatchPhysicalInventoryLine, new()
        {
            var cmd = new TMergePatchPhysicalInventoryLine();

            cmd.InventoryItemId    = state.InventoryItemId;
            cmd.BookQuantity       = state.BookQuantity;
            cmd.CountedQuantity    = state.CountedQuantity;
            cmd.Processed          = state.Processed;
            cmd.LineNumber         = state.LineNumber;
            cmd.ReversalLineNumber = state.ReversalLineNumber;
            cmd.Description        = state.Description;
            cmd.PhysicalInventoryDocumentNumber = state.PhysicalInventoryDocumentNumber;

            if (state.LineNumber == null)
            {
                cmd.IsPropertyLineNumberRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
Exemplo n.º 8
0
        public static TRemovePhysicalInventoryLine ToRemovePhysicalInventoryLine <TRemovePhysicalInventoryLine>(this IPhysicalInventoryLineState state)
            where TRemovePhysicalInventoryLine : IRemovePhysicalInventoryLine, new()
        {
            var cmd = new TRemovePhysicalInventoryLine();

            cmd.InventoryItemId = state.InventoryItemId;
            return(cmd);
        }
Exemplo n.º 9
0
        public static IPhysicalInventoryLineCommand ToCreateOrMergePatchPhysicalInventoryLine <TCreatePhysicalInventoryLine, TMergePatchPhysicalInventoryLine>(this IPhysicalInventoryLineState state)
            where TCreatePhysicalInventoryLine : ICreatePhysicalInventoryLine, new()
            where TMergePatchPhysicalInventoryLine : IMergePatchPhysicalInventoryLine, new()
        {
            bool bUnsaved = ((IPhysicalInventoryLineState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreatePhysicalInventoryLine <TCreatePhysicalInventoryLine>());
            }
            else
            {
                return(state.ToMergePatchPhysicalInventoryLine <TMergePatchPhysicalInventoryLine>());
            }
        }
Exemplo n.º 10
0
 public void AddToSave(IPhysicalInventoryLineState state)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 11
0
        public virtual void When(IPhysicalInventoryStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

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

            if (e.WarehouseId == null)
            {
                if (e.IsPropertyWarehouseIdRemoved)
                {
                    this.WarehouseId = default(string);
                }
            }
            else
            {
                this.WarehouseId = e.WarehouseId;
            }

            if (e.LocatorIdPattern == null)
            {
                if (e.IsPropertyLocatorIdPatternRemoved)
                {
                    this.LocatorIdPattern = default(string);
                }
            }
            else
            {
                this.LocatorIdPattern = e.LocatorIdPattern;
            }

            if (e.ProductIdPattern == null)
            {
                if (e.IsPropertyProductIdPatternRemoved)
                {
                    this.ProductIdPattern = default(string);
                }
            }
            else
            {
                this.ProductIdPattern = e.ProductIdPattern;
            }

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

            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.MovementDate == null)
            {
                if (e.IsPropertyMovementDateRemoved)
                {
                    this.MovementDate = default(DateTime?);
                }
            }
            else
            {
                this.MovementDate = e.MovementDate;
            }

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

            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.IsQuantityUpdated == null)
            {
                if (e.IsPropertyIsQuantityUpdatedRemoved)
                {
                    this.IsQuantityUpdated = default(bool);
                }
            }
            else
            {
                this.IsQuantityUpdated = (e.IsQuantityUpdated != null && e.IsQuantityUpdated.HasValue) ? e.IsQuantityUpdated.Value : default(bool);
            }

            if (e.ReversalDocumentNumber == null)
            {
                if (e.IsPropertyReversalDocumentNumberRemoved)
                {
                    this.ReversalDocumentNumber = default(string);
                }
            }
            else
            {
                this.ReversalDocumentNumber = e.ReversalDocumentNumber;
            }

            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 (IPhysicalInventoryLineEvent innerEvent in e.PhysicalInventoryLineEvents)
            {
                IPhysicalInventoryLineState innerState = this.PhysicalInventoryLines.Get(innerEvent.GlobalId.InventoryItemId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IPhysicalInventoryLineStateRemoved;
                if (removed != null)
                {
                    this.PhysicalInventoryLines.Remove(innerState);
                }
            }
        }
Exemplo n.º 12
0
 public virtual void Remove(IPhysicalInventoryLineState state)
 {
     this._removedPhysicalInventoryLineStates.Add(state.GlobalId, state);
 }
Exemplo n.º 13
0
 public virtual void AddToSave(IPhysicalInventoryLineState state)
 {
     this._loadedPhysicalInventoryLineStates[state.GlobalId] = state;
 }