Ejemplo n.º 1
0
        public virtual void Initialize(ISellableInventoryItemEntryMvoStateCreated stateCreated)
        {
            var aggregateId = stateCreated.SellableInventoryItemEntryMvoEventId.SellableInventoryItemEntryId;
            var state       = new SellableInventoryItemEntryMvoState();

            state.SellableInventoryItemEntryId = aggregateId;
            var aggregate = (SellableInventoryItemEntryMvoAggregate)GetSellableInventoryItemEntryMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
        public virtual void When(ISellableInventoryItemEntryMvoStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.SellableQuantity = (e.SellableQuantity != null && e.SellableQuantity.HasValue) ? e.SellableQuantity.Value : default(decimal);

            this.SourceEventId = e.SourceEventId;

            this.Version = (e.Version != null && e.Version.HasValue) ? e.Version.Value : default(long);

            this.SellableInventoryItemSellableQuantity = (e.SellableInventoryItemSellableQuantity != null && e.SellableInventoryItemSellableQuantity.HasValue) ? e.SellableInventoryItemSellableQuantity.Value : default(decimal);

            this.SellableInventoryItemCreatedBy = e.SellableInventoryItemCreatedBy;

            this.SellableInventoryItemCreatedAt = (e.SellableInventoryItemCreatedAt != null && e.SellableInventoryItemCreatedAt.HasValue) ? e.SellableInventoryItemCreatedAt.Value : default(DateTime);

            this.SellableInventoryItemUpdatedBy = e.SellableInventoryItemUpdatedBy;

            this.SellableInventoryItemUpdatedAt = (e.SellableInventoryItemUpdatedAt != null && e.SellableInventoryItemUpdatedAt.HasValue) ? e.SellableInventoryItemUpdatedAt.Value : default(DateTime);

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Ejemplo n.º 3
0
        protected virtual ISellableInventoryItemEntryMvoStateCreated Map(ICreateSellableInventoryItemEntryMvo c)
        {
            var stateEventId = new SellableInventoryItemEntryMvoEventId(c.SellableInventoryItemEntryId, c.SellableInventoryItemVersion);
            ISellableInventoryItemEntryMvoStateCreated e = NewSellableInventoryItemEntryMvoStateCreated(stateEventId);

            e.SellableQuantity = c.SellableQuantity;
            e.SourceEventId    = c.SourceEventId;
            e.Version          = c.Version;
            e.SellableInventoryItemSellableQuantity = c.SellableInventoryItemSellableQuantity;
            e.SellableInventoryItemCreatedBy        = c.SellableInventoryItemCreatedBy;
            e.SellableInventoryItemCreatedAt        = c.SellableInventoryItemCreatedAt;
            e.SellableInventoryItemUpdatedBy        = c.SellableInventoryItemUpdatedBy;
            e.SellableInventoryItemUpdatedAt        = c.SellableInventoryItemUpdatedAt;
            e.CommandId = c.CommandId;


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


            return(e);
        }
        public virtual SellableInventoryItemEntryMvoStateCreatedDto ToSellableInventoryItemEntryMvoStateCreatedDto(ISellableInventoryItemEntryMvoStateCreated e)
        {
            var dto = new SellableInventoryItemEntryMvoStateCreatedDto();

            dto.SellableInventoryItemEntryMvoEventId = e.SellableInventoryItemEntryMvoEventId;
            dto.CreatedAt        = e.CreatedAt;
            dto.CreatedBy        = e.CreatedBy;
            dto.CommandId        = e.CommandId;
            dto.SellableQuantity = e.SellableQuantity;
            dto.SourceEventId    = e.SourceEventId;
            dto.Version          = e.Version;
            dto.SellableInventoryItemSellableQuantity = e.SellableInventoryItemSellableQuantity;
            dto.SellableInventoryItemCreatedBy        = e.SellableInventoryItemCreatedBy;
            dto.SellableInventoryItemCreatedAt        = e.SellableInventoryItemCreatedAt;
            dto.SellableInventoryItemUpdatedBy        = e.SellableInventoryItemUpdatedBy;
            dto.SellableInventoryItemUpdatedAt        = e.SellableInventoryItemUpdatedAt;
            return(dto);
        }
Ejemplo n.º 5
0
 void ISellableInventoryItemEntryMvoState.When(ISellableInventoryItemEntryMvoStateCreated e)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 6
0
        public virtual void Create(ICreateSellableInventoryItemEntryMvo c)
        {
            ISellableInventoryItemEntryMvoStateCreated e = Map(c);

            Apply(e);
        }