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); }
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); }
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; }
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); }
public virtual void Create(ICreateLot c) { ILotStateCreated e = Map(c); Apply(e); }
void ILotState.When(ILotStateCreated e) { throw new NotSupportedException(); }