Beispiel #1
0
        public virtual LotStateCreatedDto ToLotStateCreatedDto(ILotStateCreated e)
        {
            var dto = new LotStateCreatedDto();

            dto.LotEventId     = e.LotEventId;
            dto.CreatedAt      = e.CreatedAt;
            dto.CreatedBy      = e.CreatedBy;
            dto.CommandId      = e.CommandId;
            dto.Quantity       = e.Quantity;
            dto.ExpirationDate = e.ExpirationDate;
            dto.Active         = e.Active;
            return(dto);
        }
Beispiel #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);
        }
Beispiel #3
0
        public virtual void When(ILotStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Quantity = e.Quantity;

            this.ExpirationDate = e.ExpirationDate;

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Beispiel #4
0
        protected virtual ILotStateCreated Map(ICreateLot c)
        {
            var stateEventId   = new LotEventId(c.LotId, c.Version);
            ILotStateCreated e = NewLotStateCreated(stateEventId);

            e.Quantity       = c.Quantity;
            e.ExpirationDate = c.ExpirationDate;
            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);
        }
Beispiel #5
0
        public virtual void Create(ICreateLot c)
        {
            ILotStateCreated e = Map(c);

            Apply(e);
        }
Beispiel #6
0
 void ILotState.When(ILotStateCreated e)
 {
     throw new NotSupportedException();
 }