コード例 #1
0
        public virtual void When(ISellableInventoryItemStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

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


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


            foreach (ISellableInventoryItemEntryEvent innerEvent in e.SellableInventoryItemEntryEvents)
            {
                ISellableInventoryItemEntryState innerState = this.Entries.Get(innerEvent.GlobalId.EntrySeqId);

                innerState.Mutate(innerEvent);
            }
        }
コード例 #2
0
        protected virtual ISellableInventoryItemStateMergePatched Map(IMergePatchSellableInventoryItem c)
        {
            var stateEventId = new SellableInventoryItemEventId(c.SellableInventoryItemId, c.Version);
            ISellableInventoryItemStateMergePatched e = NewSellableInventoryItemStateMergePatched(stateEventId);


            e.CommandId = c.CommandId;


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

            var version = c.Version;

            decimal sellableQuantity = _state.SellableQuantity;

            foreach (ISellableInventoryItemEntryCommand innerCommand in c.SellableInventoryItemEntryCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                ISellableInventoryItemEntryEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddSellableInventoryItemEntryEvent(innerEvent);
                // ////////////////
                if (!(innerEvent is ISellableInventoryItemEntryStateCreated))
                {
                    continue;
                }
                var entryCreated = (ISellableInventoryItemEntryStateCreated)innerEvent;
                sellableQuantity = sellableQuantity + (entryCreated.SellableQuantity != null ? entryCreated.SellableQuantity.GetValueOrDefault() : default(decimal));
                // ////////////////
            }

            e.SellableQuantity = sellableQuantity;

            return(e);
        }
コード例 #3
0
        public virtual SellableInventoryItemStateMergePatchedDto ToSellableInventoryItemStateMergePatchedDto(ISellableInventoryItemStateMergePatched e)
        {
            var dto = new SellableInventoryItemStateMergePatchedDto();

            dto.SellableInventoryItemEventId = e.SellableInventoryItemEventId;
            dto.CreatedAt        = e.CreatedAt;
            dto.CreatedBy        = e.CreatedBy;
            dto.CommandId        = e.CommandId;
            dto.SellableQuantity = e.SellableQuantity;
            dto.IsPropertySellableQuantityRemoved = e.IsPropertySellableQuantityRemoved;
            var sellableInventoryItemEntryEvents = new List <SellableInventoryItemEntryStateCreatedOrMergePatchedOrRemovedDto>();

            foreach (var ee in e.SellableInventoryItemEntryEvents)
            {
                SellableInventoryItemEntryStateCreatedOrMergePatchedOrRemovedDto eeDto = SellableInventoryItemEntryStateEventDtoConverter.ToSellableInventoryItemEntryStateEventDto(ee);
                sellableInventoryItemEntryEvents.Add(eeDto);
            }
            dto.SellableInventoryItemEntryEvents = sellableInventoryItemEntryEvents.ToArray();


            return(dto);
        }
コード例 #4
0
        public virtual void MergePatch(IMergePatchSellableInventoryItem c)
        {
            ISellableInventoryItemStateMergePatched e = Map(c);

            Apply(e);
        }
コード例 #5
0
 void ISellableInventoryItemState.When(ISellableInventoryItemStateMergePatched e)
 {
     throw new NotSupportedException();
 }