public virtual IAttributeState ToAttributeState() { var state = new AttributeState(true); state.AttributeId = this.AttributeId; state.AttributeName = this.AttributeName; state.OrganizationId = this.OrganizationId; state.Description = this.Description; if (this.IsMandatory != null && this.IsMandatory.HasValue) { state.IsMandatory = this.IsMandatory.Value; } state.AttributeValueType = this.AttributeValueType; state.AttributeValueLength = this.AttributeValueLength; if (this.IsList != null && this.IsList.HasValue) { state.IsList = this.IsList.Value; } state.FieldName = this.FieldName; state.ReferenceId = this.ReferenceId; if (this.Active != null && this.Active.HasValue) { state.Active = this.Active.Value; } if (this.Version != null && this.Version.HasValue) { state.Version = this.Version.Value; } state.CreatedBy = this.CreatedBy; if (this.CreatedAt != null && this.CreatedAt.HasValue) { state.CreatedAt = this.CreatedAt.Value; } state.UpdatedBy = this.UpdatedBy; if (this.UpdatedAt != null && this.UpdatedAt.HasValue) { state.UpdatedAt = this.UpdatedAt.Value; } if (this.AttributeValues != null) { foreach (var s in this.AttributeValues) { state.AttributeValues.AddToSave(s.ToAttributeValueState()); } } ; if (this.Aliases != null) { foreach (var s in this.Aliases) { state.Aliases.AddToSave(s.ToAttributeAliasState()); } } ; return(state); }
public virtual void Initialize(IAttributeStateCreated stateCreated) { var aggregateId = stateCreated.AttributeEventId.AttributeId; var state = new AttributeState(); state.AttributeId = aggregateId; var aggregate = (AttributeAggregate)GetAttributeAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public static CreateAttribute ToCreateAttribute(this AttributeState state) { return(state.ToCreateAttribute <CreateAttribute, CreateAttributeValue>()); }
public static MergePatchAttribute ToMergePatchAttribute(this AttributeState state) { return(state.ToMergePatchAttribute <MergePatchAttribute, CreateAttributeValue, MergePatchAttributeValue>()); }
public static DeleteAttribute ToDeleteAttribute(this AttributeState state) { return(state.ToDeleteAttribute <DeleteAttribute>()); }
public static IAttributeCommand ToCreateOrMergePatchAttribute(this AttributeState state) { return(state.ToCreateOrMergePatchAttribute <CreateAttribute, MergePatchAttribute, CreateAttributeValue, MergePatchAttributeValue>()); }