protected virtual IAttributeSetStateCreated Map(ICreateAttributeSet c) { var stateEventId = new AttributeSetStateEventId(c.AttributeSetId, c.Version); IAttributeSetStateCreated e = NewAttributeSetStateCreated(stateEventId); e.Name = c.Name; e.OrganizationId = c.OrganizationId; e.Description = c.Description; e.SerialNumberAttributeId = c.SerialNumberAttributeId; e.LotAttributeId = c.LotAttributeId; e.ReferenceId = c.ReferenceId; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; var version = c.Version; foreach (ICreateAttributeUse innerCommand in c.AttributeUses) { ThrowOnInconsistentCommands(c, innerCommand); IAttributeUseStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddAttributeUseEvent(innerEvent); } return(e); }
protected virtual IAttributeSetStateCreated Map(ICreateAttributeSet c) { var stateEventId = new AttributeSetEventId(c.AttributeSetId, c.Version); IAttributeSetStateCreated e = NewAttributeSetStateCreated(stateEventId); e.AttributeSetName = c.AttributeSetName; e.OrganizationId = c.OrganizationId; e.Description = c.Description; e.ReferenceId = c.ReferenceId; e.IsInstanceAttributeSet = c.IsInstanceAttributeSet; e.IsMandatory = c.IsMandatory; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (ICreateAttributeUse innerCommand in c.AttributeUses) { ThrowOnInconsistentCommands(c, innerCommand); IAttributeUseStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddAttributeUseEvent(innerEvent); } return(e); }
public virtual void When(IAttributeSetStateCreated e) { ThrowOnWrongEvent(e); this.AttributeSetName = e.AttributeSetName; this.OrganizationId = e.OrganizationId; this.Description = e.Description; this.ReferenceId = e.ReferenceId; if (e.IsInstanceAttributeSet != null) { this.IsInstanceAttributeSet = (e.IsInstanceAttributeSet != null && e.IsInstanceAttributeSet.HasValue) ? e.IsInstanceAttributeSet.Value : default(bool); } if (e.IsMandatory != null) { this.IsMandatory = (e.IsMandatory != null && e.IsMandatory.HasValue) ? e.IsMandatory.Value : default(bool); } this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.Deleted = false; this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IAttributeUseStateCreated innerEvent in e.AttributeUseEvents) { IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId, true); innerState.Mutate(innerEvent); } }
public virtual AttributeSetStateCreatedDto ToAttributeSetStateCreatedDto(IAttributeSetStateCreated e) { var dto = new AttributeSetStateCreatedDto(); dto.StateEventId = new AttributeSetStateEventIdDtoWrapper(e.StateEventId); dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.Name = e.Name; dto.OrganizationId = e.OrganizationId; dto.Description = e.Description; dto.SerialNumberAttributeId = e.SerialNumberAttributeId; dto.LotAttributeId = e.LotAttributeId; dto.ReferenceId = e.ReferenceId; dto.Active = e.Active; var attributeUseEvents = new List <AttributeUseStateCreatedDto>(); foreach (var ee in e.AttributeUseEvents) { AttributeUseStateCreatedDto eeDto = AttributeUseStateEventDtoConverter.ToAttributeUseStateCreatedDto(ee); attributeUseEvents.Add(eeDto); } dto.AttributeUseEvents = attributeUseEvents.ToArray(); return(dto); }
public virtual void When(IAttributeSetStateCreated e) { ThrowOnWrongEvent(e); this.Name = e.Name; this.OrganizationId = e.OrganizationId; this.Description = e.Description; this.SerialNumberAttributeId = e.SerialNumberAttributeId; this.LotAttributeId = e.LotAttributeId; this.ReferenceId = e.ReferenceId; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.Deleted = false; this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IAttributeUseStateCreated innerEvent in e.AttributeUseEvents) { IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId); innerState.Mutate(innerEvent); } }
public virtual AttributeSetStateCreatedDto ToAttributeSetStateCreatedDto(IAttributeSetStateCreated e) { var dto = new AttributeSetStateCreatedDto(); dto.AttributeSetEventId = e.AttributeSetEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.AttributeSetName = e.AttributeSetName; dto.OrganizationId = e.OrganizationId; dto.Description = e.Description; dto.ReferenceId = e.ReferenceId; dto.IsInstanceAttributeSet = e.IsInstanceAttributeSet; dto.IsMandatory = e.IsMandatory; dto.Active = e.Active; var attributeUseEvents = new List <AttributeUseStateCreatedDto>(); foreach (var ee in e.AttributeUseEvents) { AttributeUseStateCreatedDto eeDto = AttributeUseStateEventDtoConverter.ToAttributeUseStateCreatedDto(ee); attributeUseEvents.Add(eeDto); } dto.AttributeUseEvents = attributeUseEvents.ToArray(); return(dto); }
public virtual void Initialize(IAttributeSetStateCreated stateCreated) { var aggregateId = stateCreated.AttributeSetEventId.AttributeSetId; var state = new AttributeSetState(); state.AttributeSetId = aggregateId; var aggregate = (AttributeSetAggregate)GetAttributeSetAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual void Create(ICreateAttributeSet c) { IAttributeSetStateCreated e = Map(c); Apply(e); }
void IAttributeSetState.When(IAttributeSetStateCreated e) { throw new NotSupportedException(); }