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);
        }
        public virtual void MergePatch(IMergePatchSellableInventoryItem c)
        {
            ISellableInventoryItemStateMergePatched e = Map(c);

            Apply(e);
        }
 void ISellableInventoryItemApplicationService.When(IMergePatchSellableInventoryItem c)
 {
     this.When((MergePatchSellableInventoryItemDto)c);
 }
 public virtual void When(IMergePatchSellableInventoryItem c)
 {
     Update(c, ar => ar.MergePatch(c));
 }