Ejemplo n.º 1
0
        protected virtual IAttributeValueMvoStateCreated Map(ICreateAttributeValueMvo c)
        {
            var stateEventId = new AttributeValueMvoEventId(c.AttributeValueId, c.AttributeVersion);
            IAttributeValueMvoStateCreated e = NewAttributeValueMvoStateCreated(stateEventId);

            e.AttributeValueName            = c.AttributeValueName;
            e.Description                   = c.Description;
            e.ReferenceId                   = c.ReferenceId;
            e.Version                       = c.Version;
            e.Active                        = c.Active;
            e.AttributeAttributeName        = c.AttributeAttributeName;
            e.AttributeOrganizationId       = c.AttributeOrganizationId;
            e.AttributeDescription          = c.AttributeDescription;
            e.AttributeIsMandatory          = c.AttributeIsMandatory;
            e.AttributeAttributeValueType   = c.AttributeAttributeValueType;
            e.AttributeAttributeValueLength = c.AttributeAttributeValueLength;
            e.AttributeIsList               = c.AttributeIsList;
            e.AttributeFieldName            = c.AttributeFieldName;
            e.AttributeReferenceId          = c.AttributeReferenceId;
            e.AttributeCreatedBy            = c.AttributeCreatedBy;
            e.AttributeCreatedAt            = c.AttributeCreatedAt;
            e.AttributeUpdatedBy            = c.AttributeUpdatedBy;
            e.AttributeUpdatedAt            = c.AttributeUpdatedAt;
            e.AttributeActive               = c.AttributeActive;
            e.AttributeDeleted              = c.AttributeDeleted;
            e.CommandId                     = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            var attributeVersion = c.AttributeVersion;


            return(e);
        }
        public virtual void Initialize(IAttributeValueMvoStateCreated stateCreated)
        {
            var aggregateId = stateCreated.AttributeValueMvoEventId.AttributeValueId;
            var state       = new AttributeValueMvoState();

            state.AttributeValueId = aggregateId;
            var aggregate = (AttributeValueMvoAggregate)GetAttributeValueMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Ejemplo n.º 3
0
        public virtual void When(IAttributeValueMvoStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Name = e.Name;

            this.Description = e.Description;

            this.ReferenceId = e.ReferenceId;

            this.Version = (e.Version != null && e.Version.HasValue) ? e.Version.Value : default(long);

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.AttributeName = e.AttributeName;

            this.AttributeOrganizationId = e.AttributeOrganizationId;

            this.AttributeDescription = e.AttributeDescription;

            this.AttributeIsMandatory = (e.AttributeIsMandatory != null && e.AttributeIsMandatory.HasValue) ? e.AttributeIsMandatory.Value : default(bool);

            this.AttributeIsInstanceAttribute = (e.AttributeIsInstanceAttribute != null && e.AttributeIsInstanceAttribute.HasValue) ? e.AttributeIsInstanceAttribute.Value : default(bool);

            this.AttributeAttributeValueType = e.AttributeAttributeValueType;

            this.AttributeAttributeValueLength = e.AttributeAttributeValueLength;

            this.AttributeIsList = (e.AttributeIsList != null && e.AttributeIsList.HasValue) ? e.AttributeIsList.Value : default(bool);

            this.AttributeFieldName = e.AttributeFieldName;

            this.AttributeReferenceId = e.AttributeReferenceId;

            this.AttributeCreatedBy = e.AttributeCreatedBy;

            this.AttributeCreatedAt = (e.AttributeCreatedAt != null && e.AttributeCreatedAt.HasValue) ? e.AttributeCreatedAt.Value : default(DateTime);

            this.AttributeUpdatedBy = e.AttributeUpdatedBy;

            this.AttributeUpdatedAt = (e.AttributeUpdatedAt != null && e.AttributeUpdatedAt.HasValue) ? e.AttributeUpdatedAt.Value : default(DateTime);

            this.AttributeActive = (e.AttributeActive != null && e.AttributeActive.HasValue) ? e.AttributeActive.Value : default(bool);

            this.AttributeDeleted = (e.AttributeDeleted != null && e.AttributeDeleted.HasValue) ? e.AttributeDeleted.Value : default(bool);

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Ejemplo n.º 4
0
        protected virtual IAttributeValueMvoStateCreated Map(ICreateAttributeValueMvo c)
        {
            var stateEventId = new AttributeValueMvoStateEventId(c.AttributeValueId, c.AttributeVersion);
            IAttributeValueMvoStateCreated e = NewAttributeValueMvoStateCreated(stateEventId);

            e.Name                          = c.Name;
            e.Description                   = c.Description;
            e.ReferenceId                   = c.ReferenceId;
            e.Version                       = c.Version;
            e.Active                        = c.Active;
            e.AttributeName                 = c.AttributeName;
            e.AttributeOrganizationId       = c.AttributeOrganizationId;
            e.AttributeDescription          = c.AttributeDescription;
            e.AttributeIsMandatory          = c.AttributeIsMandatory;
            e.AttributeIsInstanceAttribute  = c.AttributeIsInstanceAttribute;
            e.AttributeAttributeValueType   = c.AttributeAttributeValueType;
            e.AttributeAttributeValueLength = c.AttributeAttributeValueLength;
            e.AttributeIsList               = c.AttributeIsList;
            e.AttributeFieldName            = c.AttributeFieldName;
            e.AttributeReferenceId          = c.AttributeReferenceId;
            e.AttributeCreatedBy            = c.AttributeCreatedBy;
            e.AttributeCreatedAt            = c.AttributeCreatedAt;
            e.AttributeUpdatedBy            = c.AttributeUpdatedBy;
            e.AttributeUpdatedAt            = c.AttributeUpdatedAt;
            e.AttributeActive               = c.AttributeActive;
            e.AttributeDeleted              = c.AttributeDeleted;
            ReflectUtils.CopyPropertyValue("CommandId", c, e);


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = DateTime.Now;
            var attributeVersion = c.AttributeVersion;


            return(e);
        }
Ejemplo n.º 5
0
 void IAttributeValueMvoState.When(IAttributeValueMvoStateCreated e)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 6
0
        public virtual AttributeValueMvoStateCreatedDto ToAttributeValueMvoStateCreatedDto(IAttributeValueMvoStateCreated e)
        {
            var dto = new AttributeValueMvoStateCreatedDto();

            dto.StateEventId                  = new AttributeValueMvoStateEventIdDtoWrapper(e.StateEventId);
            dto.CreatedAt                     = e.CreatedAt;
            dto.CreatedBy                     = e.CreatedBy;
            dto.CommandId                     = e.CommandId;
            dto.Name                          = e.Name;
            dto.Description                   = e.Description;
            dto.ReferenceId                   = e.ReferenceId;
            dto.Version                       = e.Version;
            dto.Active                        = e.Active;
            dto.AttributeName                 = e.AttributeName;
            dto.AttributeOrganizationId       = e.AttributeOrganizationId;
            dto.AttributeDescription          = e.AttributeDescription;
            dto.AttributeIsMandatory          = e.AttributeIsMandatory;
            dto.AttributeIsInstanceAttribute  = e.AttributeIsInstanceAttribute;
            dto.AttributeAttributeValueType   = e.AttributeAttributeValueType;
            dto.AttributeAttributeValueLength = e.AttributeAttributeValueLength;
            dto.AttributeIsList               = e.AttributeIsList;
            dto.AttributeFieldName            = e.AttributeFieldName;
            dto.AttributeReferenceId          = e.AttributeReferenceId;
            dto.AttributeCreatedBy            = e.AttributeCreatedBy;
            dto.AttributeCreatedAt            = e.AttributeCreatedAt;
            dto.AttributeUpdatedBy            = e.AttributeUpdatedBy;
            dto.AttributeUpdatedAt            = e.AttributeUpdatedAt;
            dto.AttributeActive               = e.AttributeActive;
            dto.AttributeDeleted              = e.AttributeDeleted;
            return(dto);
        }
Ejemplo n.º 7
0
        public virtual void Create(ICreateAttributeValueMvo c)
        {
            IAttributeValueMvoStateCreated e = Map(c);

            Apply(e);
        }