protected virtual ISellableInventoryItemStateCreated Map(ICreateSellableInventoryItem c)
        {
            var stateEventId = new SellableInventoryItemEventId(c.SellableInventoryItemId, c.Version);
            ISellableInventoryItemStateCreated e = NewSellableInventoryItemStateCreated(stateEventId);

            e.CommandId = c.CommandId;


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

            decimal sellableQuantity = default(decimal);

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

                ISellableInventoryItemEntryStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddSellableInventoryItemEntryEvent(innerEvent);
                sellableQuantity = sellableQuantity + (innerEvent.SellableQuantity != null ? innerEvent.SellableQuantity.GetValueOrDefault() : default(decimal));
            }

            e.SellableQuantity = sellableQuantity;

            return(e);
        }
        public virtual void When(ISellableInventoryItemEntryStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.SellableQuantity = (e.SellableQuantity != null && e.SellableQuantity.HasValue) ? e.SellableQuantity.Value : default(decimal);

            this.SourceEventId = e.SourceEventId;

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
        protected virtual ISellableInventoryItemEntryStateCreated MapCreate(ICreateSellableInventoryItemEntry c, ISellableInventoryItemCommand outerCommand, long version, ISellableInventoryItemState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId = new SellableInventoryItemEntryEventId(c.SellableInventoryItemId, c.EntrySeqId, version);
            ISellableInventoryItemEntryStateCreated e = NewSellableInventoryItemEntryStateCreated(stateEventId);
            var s = outerState.Entries.Get(c.EntrySeqId, true);

            e.SellableQuantity = c.SellableQuantity;
            e.SourceEventId    = c.SourceEventId;

            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            return(e);
        }// END Map(ICreate... ////////////////////////////
예제 #4
0
 void ISellableInventoryItemStateCreated.AddSellableInventoryItemEntryEvent(ISellableInventoryItemEntryStateCreated e)
 {
     this._sellableInventoryItemEntryEvents.AddSellableInventoryItemEntryEvent(e);
 }
예제 #5
0
 public virtual void AddSellableInventoryItemEntryEvent(ISellableInventoryItemEntryStateCreated e)
 {
     ThrowOnInconsistentEventIds(e);
     this._sellableInventoryItemEntryEvents[e.SellableInventoryItemEntryEventId] = e;
 }
        public virtual SellableInventoryItemEntryStateCreatedDto ToSellableInventoryItemEntryStateCreatedDto(ISellableInventoryItemEntryStateCreated e)
        {
            var dto = new SellableInventoryItemEntryStateCreatedDto();

            dto.SellableInventoryItemEntryEventId = e.SellableInventoryItemEntryEventId;
            dto.CreatedAt        = e.CreatedAt;
            dto.CreatedBy        = e.CreatedBy;
            dto.Version          = e.Version;
            dto.CommandId        = e.CommandId;
            dto.SellableQuantity = e.SellableQuantity;
            dto.SourceEventId    = e.SourceEventId;
            return(dto);
        }
 void ISellableInventoryItemEntryState.When(ISellableInventoryItemEntryStateCreated e)
 {
     throw new NotSupportedException();
 }