Exemplo n.º 1
0
        protected virtual IInventoryItemRequirementStateCreated Map(ICreateInventoryItemRequirement c)
        {
            var stateEventId = new InventoryItemRequirementEventId(c.InventoryItemRequirementId, c.Version);
            IInventoryItemRequirementStateCreated e = NewInventoryItemRequirementStateCreated(stateEventId);

            e.CommandId = c.CommandId;


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

            decimal quantity = default(decimal);

            foreach (ICreateInventoryItemRequirementEntry innerCommand in c.Entries)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IInventoryItemRequirementEntryStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddInventoryItemRequirementEntryEvent(innerEvent);
                quantity = quantity + (innerEvent.Quantity != null ? innerEvent.Quantity.GetValueOrDefault() : default(decimal));
            }

            e.Quantity = quantity;

            return(e);
        }
Exemplo n.º 2
0
        protected InventoryItemRequirementStateMergePatched NewInventoryItemRequirementStateMergePatched(long version, string commandId, string requesterId)
        {
            var stateEventId = new InventoryItemRequirementEventId(_state.InventoryItemRequirementId, version);
            var e            = NewInventoryItemRequirementStateMergePatched(stateEventId);

            e.CommandId = commandId;

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

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

            InventoryItemRequirementEventId other = obj as InventoryItemRequirementEventId;

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

            return(true &&
                   Object.Equals(this.InventoryItemRequirementId, other.InventoryItemRequirementId) &&
                   Object.Equals(this.Version, other.Version)
                   );
        }
Exemplo n.º 4
0
        protected virtual IInventoryItemRequirementStateMergePatched Map(IMergePatchInventoryItemRequirement c)
        {
            var stateEventId = new InventoryItemRequirementEventId(c.InventoryItemRequirementId, c.Version);
            IInventoryItemRequirementStateMergePatched e = NewInventoryItemRequirementStateMergePatched(stateEventId);


            e.CommandId = c.CommandId;


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

            var version = c.Version;

            decimal quantity = _state.Quantity;

            foreach (IInventoryItemRequirementEntryCommand innerCommand in c.InventoryItemRequirementEntryCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IInventoryItemRequirementEntryEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddInventoryItemRequirementEntryEvent(innerEvent);
                // ////////////////
                if (!(innerEvent is IInventoryItemRequirementEntryStateCreated))
                {
                    continue;
                }
                var entryCreated = (IInventoryItemRequirementEntryStateCreated)innerEvent;
                quantity = quantity + (entryCreated.Quantity != null ? entryCreated.Quantity.GetValueOrDefault() : default(decimal));
                // ////////////////
            }

            e.Quantity = quantity;

            return(e);
        }
Exemplo n.º 5
0
 protected InventoryItemRequirementEventBase(InventoryItemRequirementEventId stateEventId)
 {
     this.InventoryItemRequirementEventId = stateEventId;
 }
Exemplo n.º 6
0
 public InventoryItemRequirementStateMergePatched(InventoryItemRequirementEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 7
0
 public InventoryItemRequirementStateCreated(InventoryItemRequirementEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 8
0
 protected InventoryItemRequirementStateEventBase(InventoryItemRequirementEventId stateEventId) : base(stateEventId)
 {
 }
Exemplo n.º 9
0
 private InventoryItemRequirementStateMergePatched NewInventoryItemRequirementStateMergePatched(InventoryItemRequirementEventId stateEventId)
 {
     return(new InventoryItemRequirementStateMergePatched(stateEventId));
 }
Exemplo n.º 10
0
////////////////////////

        private InventoryItemRequirementStateCreated NewInventoryItemRequirementStateCreated(InventoryItemRequirementEventId stateEventId)
        {
            return(new InventoryItemRequirementStateCreated(stateEventId));
        }