Example #1
0
        public virtual ILotState ToLotState()
        {
            var state = new LotState(true);

            state.LotId          = this.LotId;
            state.Quantity       = this.Quantity;
            state.ExpirationDate = this.ExpirationDate;
            if (this.Active != null && this.Active.HasValue)
            {
                state.Active = this.Active.Value;
            }
            if (this.Version != null && this.Version.HasValue)
            {
                state.Version = this.Version.Value;
            }
            state.CreatedBy = this.CreatedBy;
            if (this.CreatedAt != null && this.CreatedAt.HasValue)
            {
                state.CreatedAt = this.CreatedAt.Value;
            }
            state.UpdatedBy = this.UpdatedBy;
            if (this.UpdatedAt != null && this.UpdatedAt.HasValue)
            {
                state.UpdatedAt = this.UpdatedAt.Value;
            }

            return(state);
        }
Example #2
0
        public virtual void Initialize(ILotStateCreated stateCreated)
        {
            var aggregateId = stateCreated.LotEventId.LotId;
            var state       = new LotState();

            state.LotId = aggregateId;
            var aggregate = (LotAggregate)GetLotAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Example #3
0
 public static CreateLot ToCreateLot(this LotState state)
 {
     return(state.ToCreateLot <CreateLot>());
 }
Example #4
0
 public static MergePatchLot ToMergePatchLot(this LotState state)
 {
     return(state.ToMergePatchLot <MergePatchLot>());
 }
Example #5
0
 public static DeleteLot ToDeleteLot(this LotState state)
 {
     return(state.ToDeleteLot <DeleteLot>());
 }
Example #6
0
 public static ILotCommand ToCreateOrMergePatchLot(this LotState state)
 {
     return(state.ToCreateOrMergePatchLot <CreateLot, MergePatchLot>());
 }