Exemplo n.º 1
0
        protected InventoryItemStateMergePatched NewInventoryItemStateMergePatched(long version, string commandId, string requesterId)
        {
            var stateEventId = new InventoryItemEventId(_state.InventoryItemId, version);
            var e            = NewInventoryItemStateMergePatched(stateEventId);

            e.CommandId = commandId;

            e.CreatedBy = (string)requesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();

            return(e);
        }
Exemplo n.º 2
0
        protected virtual IInventoryItemStateMergePatched Map(IMergePatchInventoryItem c)
        {
            var stateEventId = new InventoryItemEventId(c.InventoryItemId, c.Version);
            IInventoryItemStateMergePatched e = NewInventoryItemStateMergePatched(stateEventId);


            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();

            var version = c.Version;

            decimal onHandQuantity    = _state.OnHandQuantity;
            decimal inTransitQuantity = _state.InTransitQuantity;
            decimal reservedQuantity  = _state.ReservedQuantity;
            decimal occupiedQuantity  = _state.OccupiedQuantity;
            decimal virtualQuantity   = _state.VirtualQuantity;

            foreach (IInventoryItemEntryCommand innerCommand in c.InventoryItemEntryCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IInventoryItemEntryEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddInventoryItemEntryEvent(innerEvent);
                // ////////////////
                if (!(innerEvent is IInventoryItemEntryStateCreated))
                {
                    continue;
                }
                var entryCreated = (IInventoryItemEntryStateCreated)innerEvent;
                onHandQuantity    = onHandQuantity + (entryCreated.OnHandQuantity != null ? entryCreated.OnHandQuantity.GetValueOrDefault() : default(decimal));
                inTransitQuantity = inTransitQuantity + (entryCreated.InTransitQuantity != null ? entryCreated.InTransitQuantity.GetValueOrDefault() : default(decimal));
                reservedQuantity  = reservedQuantity + (entryCreated.ReservedQuantity != null ? entryCreated.ReservedQuantity.GetValueOrDefault() : default(decimal));
                occupiedQuantity  = occupiedQuantity + (entryCreated.OccupiedQuantity != null ? entryCreated.OccupiedQuantity.GetValueOrDefault() : default(decimal));
                virtualQuantity   = virtualQuantity + (entryCreated.VirtualQuantity != null ? entryCreated.VirtualQuantity.GetValueOrDefault() : default(decimal));
                // ////////////////
            }

            e.OnHandQuantity    = onHandQuantity;
            e.InTransitQuantity = inTransitQuantity;
            e.ReservedQuantity  = reservedQuantity;
            e.OccupiedQuantity  = occupiedQuantity;
            e.VirtualQuantity   = virtualQuantity;

            return(e);
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            InventoryItemEventId other = obj as InventoryItemEventId;

            if (other == null)
            {
                return(false);
            }

            return(true &&
                   Object.Equals(this.InventoryItemId, other.InventoryItemId) &&
                   Object.Equals(this.Version, other.Version)
                   );
        }
Exemplo n.º 4
0
 protected InventoryItemEventBase(InventoryItemEventId stateEventId)
 {
     this.InventoryItemEventId = stateEventId;
 }
Exemplo n.º 5
0
 public InventoryItemStateMergePatched(InventoryItemEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 6
0
 public InventoryItemStateCreated(InventoryItemEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 7
0
 protected InventoryItemStateEventBase(InventoryItemEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 8
0
 private InventoryItemStateMergePatched NewInventoryItemStateMergePatched(InventoryItemEventId stateEventId)
 {
     return(new InventoryItemStateMergePatched(stateEventId));
 }
Exemplo n.º 9
0
////////////////////////

        private InventoryItemStateCreated NewInventoryItemStateCreated(InventoryItemEventId stateEventId)
        {
            return(new InventoryItemStateCreated(stateEventId));
        }