示例#1
0
        protected virtual IAttributeStateCreated Map(ICreateAttribute c)
        {
            var stateEventId         = new AttributeStateEventId(c.AttributeId, c.Version);
            IAttributeStateCreated e = NewAttributeStateCreated(stateEventId);

            e.Name                 = c.Name;
            e.OrganizationId       = c.OrganizationId;
            e.Description          = c.Description;
            e.IsMandatory          = c.IsMandatory;
            e.IsInstanceAttribute  = c.IsInstanceAttribute;
            e.AttributeValueType   = c.AttributeValueType;
            e.AttributeValueLength = c.AttributeValueLength;
            e.IsList               = c.IsList;
            e.FieldName            = c.FieldName;
            e.ReferenceId          = c.ReferenceId;
            e.Active               = c.Active;
            ReflectUtils.CopyPropertyValue("CommandId", c, e);


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = DateTime.Now;
            var version = c.Version;

            foreach (ICreateAttributeValue innerCommand in c.AttributeValues)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IAttributeValueStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddAttributeValueEvent(innerEvent);
            }


            return(e);
        }
示例#2
0
        public virtual AttributeValueStateCreatedDto ToAttributeValueStateCreatedDto(IAttributeValueStateCreated e)
        {
            var dto = new AttributeValueStateCreatedDto();

            dto.AttributeValueEventId = e.AttributeValueEventId;
            dto.CreatedAt             = e.CreatedAt;
            dto.CreatedBy             = e.CreatedBy;
            dto.Version            = e.Version;
            dto.CommandId          = e.CommandId;
            dto.AttributeValueName = e.AttributeValueName;
            dto.Description        = e.Description;
            dto.ReferenceId        = e.ReferenceId;
            dto.Active             = e.Active;
            return(dto);
        }
示例#3
0
        public virtual void When(IAttributeValueStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.AttributeValueName = e.AttributeValueName;

            this.Description = e.Description;

            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;
        }
示例#4
0
        protected virtual IAttributeValueStateCreated MapCreate(ICreateAttributeValue c, IAttributeCommand outerCommand, long version, IAttributeState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId = new AttributeValueStateEventId(c.AttributeId, c.Value, version);
            IAttributeValueStateCreated e = NewAttributeValueStateCreated(stateEventId);
            var s = outerState.AttributeValues.Get(c.Value);

            e.Name        = c.Name;
            e.Description = c.Description;
            e.ReferenceId = c.ReferenceId;
            e.Active      = c.Active;

            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = DateTime.Now;
            return(e);
        }// END Map(ICreate... ////////////////////////////
示例#5
0
        protected virtual IAttributeStateCreated Map(ICreateAttribute c)
        {
            var stateEventId         = new AttributeEventId(c.AttributeId, c.Version);
            IAttributeStateCreated e = NewAttributeStateCreated(stateEventId);

            e.AttributeName        = c.AttributeName;
            e.OrganizationId       = c.OrganizationId;
            e.Description          = c.Description;
            e.IsMandatory          = c.IsMandatory;
            e.AttributeValueType   = c.AttributeValueType;
            e.AttributeValueLength = c.AttributeValueLength;
            e.IsList      = c.IsList;
            e.FieldName   = c.FieldName;
            e.ReferenceId = c.ReferenceId;
            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 (ICreateAttributeValue innerCommand in c.AttributeValues)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IAttributeValueStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddAttributeValueEvent(innerEvent);
            }

            foreach (ICreateAttributeAlias innerCommand in c.Aliases)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IAttributeAliasStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddAttributeAliasEvent(innerEvent);
            }


            return(e);
        }
示例#6
0
 void IAttributeValueState.When(IAttributeValueStateCreated e)
 {
     throw new NotSupportedException();
 }
示例#7
0
 public virtual void AddAttributeValueEvent(IAttributeValueStateCreated e)
 {
     ThrowOnInconsistentEventIds(e);
     this._attributeValueEvents[e.StateEventId] = e;
 }
示例#8
0
 void IAttributeStateCreated.AddAttributeValueEvent(IAttributeValueStateCreated e)
 {
     this._attributeValueEvents.AddAttributeValueEvent(e);
 }