예제 #1
0
        public virtual void Initialize(IProductCategoryMemberStateCreated stateCreated)
        {
            var aggregateId = stateCreated.ProductCategoryMemberEventId.ProductCategoryMemberId;
            var state       = new ProductCategoryMemberState();

            state.ProductCategoryMemberId = aggregateId;
            var aggregate = (ProductCategoryMemberAggregate)GetProductCategoryMemberAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
예제 #2
0
        public virtual void When(IProductCategoryMemberStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.ThruDate = e.ThruDate;

            this.Comments = e.Comments;

            this.SequenceNum = e.SequenceNum;

            this.Quantity = e.Quantity;

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
예제 #3
0
        protected virtual IProductCategoryMemberStateCreated Map(ICreateProductCategoryMember c)
        {
            var stateEventId = new ProductCategoryMemberEventId(c.ProductCategoryMemberId, c.Version);
            IProductCategoryMemberStateCreated e = NewProductCategoryMemberStateCreated(stateEventId);

            e.ThruDate    = c.ThruDate;
            e.Comments    = c.Comments;
            e.SequenceNum = c.SequenceNum;
            e.Quantity    = c.Quantity;
            e.Active      = c.Active;
            e.CommandId   = c.CommandId;


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


            return(e);
        }
예제 #4
0
        public virtual void Create(ICreateProductCategoryMember c)
        {
            IProductCategoryMemberStateCreated e = Map(c);

            Apply(e);
        }
 void IProductCategoryMemberState.When(IProductCategoryMemberStateCreated e)
 {
     throw new NotSupportedException();
 }
        public virtual ProductCategoryMemberStateCreatedDto ToProductCategoryMemberStateCreatedDto(IProductCategoryMemberStateCreated e)
        {
            var dto = new ProductCategoryMemberStateCreatedDto();

            dto.ProductCategoryMemberEventId = e.ProductCategoryMemberEventId;
            dto.CreatedAt   = e.CreatedAt;
            dto.CreatedBy   = e.CreatedBy;
            dto.CommandId   = e.CommandId;
            dto.ThruDate    = e.ThruDate;
            dto.Comments    = e.Comments;
            dto.SequenceNum = e.SequenceNum;
            dto.Quantity    = e.Quantity;
            dto.Active      = e.Active;
            return(dto);
        }