public virtual void Initialize(IDamageTypeStateCreated stateCreated) { var aggregateId = stateCreated.DamageTypeEventId.DamageTypeId; var state = new DamageTypeState(); state.DamageTypeId = aggregateId; var aggregate = (DamageTypeAggregate)GetDamageTypeAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual DamageTypeStateCreatedDto ToDamageTypeStateCreatedDto(IDamageTypeStateCreated e) { var dto = new DamageTypeStateCreatedDto(); dto.DamageTypeEventId = e.DamageTypeEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.Description = e.Description; dto.SequenceId = e.SequenceId; dto.DefaultHandlingMethodId = e.DefaultHandlingMethodId; dto.Active = e.Active; return(dto); }
public virtual void When(IDamageTypeStateCreated e) { ThrowOnWrongEvent(e); this.Description = e.Description; this.SequenceId = e.SequenceId; this.DefaultHandlingMethodId = e.DefaultHandlingMethodId; 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 IDamageTypeStateCreated Map(ICreateDamageType c) { var stateEventId = new DamageTypeEventId(c.DamageTypeId, c.Version); IDamageTypeStateCreated e = NewDamageTypeStateCreated(stateEventId); e.Description = c.Description; e.SequenceId = c.SequenceId; e.DefaultHandlingMethodId = c.DefaultHandlingMethodId; 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); }
void IDamageTypeState.When(IDamageTypeStateCreated e) { throw new NotSupportedException(); }
public virtual void Create(ICreateDamageType c) { IDamageTypeStateCreated e = Map(c); Apply(e); }