Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public virtual void When(IAttributeUseStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.SequenceNumber = (e.SequenceNumber != null && e.SequenceNumber.HasValue) ? e.SequenceNumber.Value : default(int);

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
        public virtual AttributeUseStateCreatedDto ToAttributeUseStateCreatedDto(IAttributeUseStateCreated e)
        {
            var dto = new AttributeUseStateCreatedDto();

            dto.StateEventId   = new AttributeUseStateEventIdDtoWrapper(e.StateEventId);
            dto.CreatedAt      = e.CreatedAt;
            dto.CreatedBy      = e.CreatedBy;
            dto.Version        = e.Version;
            dto.CommandId      = e.CommandId;
            dto.SequenceNumber = e.SequenceNumber;
            dto.Active         = e.Active;
            return(dto);
        }
Esempio n. 5
0
        protected virtual IAttributeUseStateCreated MapCreate(ICreateAttributeUse c, IAttributeSetCommand outerCommand, long version, IAttributeSetState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId            = new AttributeUseStateEventId(c.AttributeSetId, c.AttributeId, version);
            IAttributeUseStateCreated e = NewAttributeUseStateCreated(stateEventId);
            var s = outerState.AttributeUses.Get(c.AttributeId, true);

            e.SequenceNumber = c.SequenceNumber;
            e.Active         = c.Active;

            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = DateTime.Now;
            return(e);
        }// END Map(ICreate... ////////////////////////////
 void IAttributeUseState.When(IAttributeUseStateCreated e)
 {
     throw new NotSupportedException();
 }
Esempio n. 7
0
 public virtual void AddAttributeUseEvent(IAttributeUseStateCreated e)
 {
     ThrowOnInconsistentEventIds(e);
     this._attributeUseEvents[e.AttributeUseEventId] = e;
 }
Esempio n. 8
0
 void IAttributeSetStateCreated.AddAttributeUseEvent(IAttributeUseStateCreated e)
 {
     this._attributeUseEvents.AddAttributeUseEvent(e);
 }