Exemple #1
0
        public virtual void When(IInventoryItemStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.OnHandQuantity = (e.OnHandQuantity != null && e.OnHandQuantity.HasValue) ? e.OnHandQuantity.Value : default(decimal);

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

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

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

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

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

            foreach (IInventoryItemEntryStateCreated innerEvent in e.InventoryItemEntryEvents)
            {
                IInventoryItemEntryState innerState = this.Entries.Get(innerEvent.GlobalId.EntrySeqId, true);
                innerState.Mutate(innerEvent);
            }
        }
Exemple #2
0
        public virtual void When(IInventoryItemStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

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

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

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

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

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


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


            foreach (IInventoryItemEntryEvent innerEvent in e.InventoryItemEntryEvents)
            {
                IInventoryItemEntryState innerState = this.Entries.Get(innerEvent.GlobalId.EntrySeqId);

                innerState.Mutate(innerEvent);
            }
        }