public virtual void Initialize(IInventoryItemRequirementEntryMvoStateCreated stateCreated)
        {
            var aggregateId = stateCreated.InventoryItemRequirementEntryMvoEventId.InventoryItemRequirementEntryId;
            var state       = new InventoryItemRequirementEntryMvoState();

            state.InventoryItemRequirementEntryId = aggregateId;
            var aggregate = (InventoryItemRequirementEntryMvoAggregate)GetInventoryItemRequirementEntryMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            this.SourceEventId = e.SourceEventId;

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

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

            this.InventoryItemRequirementCreatedBy = e.InventoryItemRequirementCreatedBy;

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

            this.InventoryItemRequirementUpdatedBy = e.InventoryItemRequirementUpdatedBy;

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

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Example #3
0
        protected virtual IInventoryItemRequirementEntryMvoStateCreated Map(ICreateInventoryItemRequirementEntryMvo c)
        {
            var stateEventId = new InventoryItemRequirementEntryMvoEventId(c.InventoryItemRequirementEntryId, c.InventoryItemRequirementVersion);
            IInventoryItemRequirementEntryMvoStateCreated e = NewInventoryItemRequirementEntryMvoStateCreated(stateEventId);

            e.Quantity      = c.Quantity;
            e.SourceEventId = c.SourceEventId;
            e.Version       = c.Version;
            e.InventoryItemRequirementQuantity  = c.InventoryItemRequirementQuantity;
            e.InventoryItemRequirementCreatedBy = c.InventoryItemRequirementCreatedBy;
            e.InventoryItemRequirementCreatedAt = c.InventoryItemRequirementCreatedAt;
            e.InventoryItemRequirementUpdatedBy = c.InventoryItemRequirementUpdatedBy;
            e.InventoryItemRequirementUpdatedAt = c.InventoryItemRequirementUpdatedAt;
            e.CommandId = c.CommandId;


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


            return(e);
        }
Example #4
0
        public virtual void Create(ICreateInventoryItemRequirementEntryMvo c)
        {
            IInventoryItemRequirementEntryMvoStateCreated e = Map(c);

            Apply(e);
        }
 void IInventoryItemRequirementEntryMvoState.When(IInventoryItemRequirementEntryMvoStateCreated e)
 {
     throw new NotSupportedException();
 }
Example #6
0
        public virtual InventoryItemRequirementEntryMvoStateCreatedDto ToInventoryItemRequirementEntryMvoStateCreatedDto(IInventoryItemRequirementEntryMvoStateCreated e)
        {
            var dto = new InventoryItemRequirementEntryMvoStateCreatedDto();

            dto.InventoryItemRequirementEntryMvoEventId = e.InventoryItemRequirementEntryMvoEventId;
            dto.CreatedAt     = e.CreatedAt;
            dto.CreatedBy     = e.CreatedBy;
            dto.CommandId     = e.CommandId;
            dto.Quantity      = e.Quantity;
            dto.SourceEventId = e.SourceEventId;
            dto.Version       = e.Version;
            dto.InventoryItemRequirementQuantity  = e.InventoryItemRequirementQuantity;
            dto.InventoryItemRequirementCreatedBy = e.InventoryItemRequirementCreatedBy;
            dto.InventoryItemRequirementCreatedAt = e.InventoryItemRequirementCreatedAt;
            dto.InventoryItemRequirementUpdatedBy = e.InventoryItemRequirementUpdatedBy;
            dto.InventoryItemRequirementUpdatedAt = e.InventoryItemRequirementUpdatedAt;
            return(dto);
        }