Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public virtual void When(ICreateAttribute c)
 {
     Update(c, ar => ar.Create(c));
 }
Ejemplo n.º 4
0
 void IAttributeApplicationService.When(ICreateAttribute c)
 {
     this.When((CreateAttributeDto)c);
 }
Ejemplo n.º 5
0
        public virtual void Create(ICreateAttribute c)
        {
            IAttributeStateCreated e = Map(c);

            Apply(e);
        }