public virtual void Initialize(IDocumentTypeStateCreated stateCreated) { var aggregateId = stateCreated.DocumentTypeEventId.DocumentTypeId; var state = new DocumentTypeState(); state.DocumentTypeId = aggregateId; var aggregate = (DocumentTypeAggregate)GetDocumentTypeAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual DocumentTypeStateCreatedDto ToDocumentTypeStateCreatedDto(IDocumentTypeStateCreated e) { var dto = new DocumentTypeStateCreatedDto(); dto.DocumentTypeEventId = e.DocumentTypeEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.Description = e.Description; dto.ParentDocumentTypeId = e.ParentDocumentTypeId; dto.Active = e.Active; return(dto); }
public virtual void When(IDocumentTypeStateCreated e) { ThrowOnWrongEvent(e); this.Description = e.Description; this.ParentDocumentTypeId = e.ParentDocumentTypeId; 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 IDocumentTypeStateCreated Map(ICreateDocumentType c) { var stateEventId = new DocumentTypeEventId(c.DocumentTypeId, c.Version); IDocumentTypeStateCreated e = NewDocumentTypeStateCreated(stateEventId); e.Description = c.Description; e.ParentDocumentTypeId = c.ParentDocumentTypeId; 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(ICreateDocumentType c) { IDocumentTypeStateCreated e = Map(c); Apply(e); }
void IDocumentTypeState.When(IDocumentTypeStateCreated e) { throw new NotSupportedException(); }