protected virtual IAttributeSetStateMergePatched Map(IMergePatchAttributeSet c)
        {
            var stateEventId = new AttributeSetStateEventId(c.AttributeSetId, c.Version);
            IAttributeSetStateMergePatched e = NewAttributeSetStateMergePatched(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.IsPropertyNameRemoved                    = c.IsPropertyNameRemoved;
            e.IsPropertyOrganizationIdRemoved          = c.IsPropertyOrganizationIdRemoved;
            e.IsPropertyDescriptionRemoved             = c.IsPropertyDescriptionRemoved;
            e.IsPropertySerialNumberAttributeIdRemoved = c.IsPropertySerialNumberAttributeIdRemoved;
            e.IsPropertyLotAttributeIdRemoved          = c.IsPropertyLotAttributeIdRemoved;
            e.IsPropertyReferenceIdRemoved             = c.IsPropertyReferenceIdRemoved;
            e.IsPropertyActiveRemoved                  = c.IsPropertyActiveRemoved;

            e.CommandId = c.CommandId;


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

            var version = c.Version;

            foreach (IAttributeUseCommand innerCommand in c.AttributeUseCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IAttributeUseStateEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddAttributeUseEvent(innerEvent);
            }


            return(e);
        }
Exemple #2
0
        protected virtual IAttributeSetStateMergePatched Map(IMergePatchAttributeSet c)
        {
            var stateEventId = new AttributeSetEventId(c.AttributeSetId, c.Version);
            IAttributeSetStateMergePatched e = NewAttributeSetStateMergePatched(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.IsPropertyAttributeSetNameRemoved       = c.IsPropertyAttributeSetNameRemoved;
            e.IsPropertyOrganizationIdRemoved         = c.IsPropertyOrganizationIdRemoved;
            e.IsPropertyDescriptionRemoved            = c.IsPropertyDescriptionRemoved;
            e.IsPropertyReferenceIdRemoved            = c.IsPropertyReferenceIdRemoved;
            e.IsPropertyIsInstanceAttributeSetRemoved = c.IsPropertyIsInstanceAttributeSetRemoved;
            e.IsPropertyIsMandatoryRemoved            = c.IsPropertyIsMandatoryRemoved;
            e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved;

            e.CommandId = c.CommandId;


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

            var version = c.Version;

            foreach (IAttributeUseCommand innerCommand in c.AttributeUseCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IAttributeUseEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddAttributeUseEvent(innerEvent);
            }


            return(e);
        }
        public virtual void MergePatch(IMergePatchAttributeSet c)
        {
            IAttributeSetStateMergePatched e = Map(c);

            Apply(e);
        }
Exemple #4
0
        public virtual void When(IAttributeSetStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.AttributeSetName == null)
            {
                if (e.IsPropertyAttributeSetNameRemoved)
                {
                    this.AttributeSetName = default(string);
                }
            }
            else
            {
                this.AttributeSetName = e.AttributeSetName;
            }

            if (e.OrganizationId == null)
            {
                if (e.IsPropertyOrganizationIdRemoved)
                {
                    this.OrganizationId = default(string);
                }
            }
            else
            {
                this.OrganizationId = e.OrganizationId;
            }

            if (e.Description == null)
            {
                if (e.IsPropertyDescriptionRemoved)
                {
                    this.Description = default(string);
                }
            }
            else
            {
                this.Description = e.Description;
            }

            if (e.ReferenceId == null)
            {
                if (e.IsPropertyReferenceIdRemoved)
                {
                    this.ReferenceId = default(string);
                }
            }
            else
            {
                this.ReferenceId = e.ReferenceId;
            }

            if (e.IsInstanceAttributeSet == null)
            {
                if (e.IsPropertyIsInstanceAttributeSetRemoved)
                {
                    this.IsInstanceAttributeSet = default(bool);
                }
            }
            else
            {
                this.IsInstanceAttributeSet = (e.IsInstanceAttributeSet != null && e.IsInstanceAttributeSet.HasValue) ? e.IsInstanceAttributeSet.Value : default(bool);
            }

            if (e.IsMandatory == null)
            {
                if (e.IsPropertyIsMandatoryRemoved)
                {
                    this.IsMandatory = default(bool);
                }
            }
            else
            {
                this.IsMandatory = (e.IsMandatory != null && e.IsMandatory.HasValue) ? e.IsMandatory.Value : default(bool);
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IAttributeUseEvent innerEvent in e.AttributeUseEvents)
            {
                IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IAttributeUseStateRemoved;
                if (removed != null)
                {
                    this.AttributeUses.Remove(innerState);
                }
            }
        }
        public virtual AttributeSetStateMergePatchedDto ToAttributeSetStateMergePatchedDto(IAttributeSetStateMergePatched e)
        {
            var dto = new AttributeSetStateMergePatchedDto();

            dto.StateEventId                             = new AttributeSetStateEventIdDtoWrapper(e.StateEventId);
            dto.CreatedAt                                = e.CreatedAt;
            dto.CreatedBy                                = e.CreatedBy;
            dto.CommandId                                = e.CommandId;
            dto.Name                                     = e.Name;
            dto.OrganizationId                           = e.OrganizationId;
            dto.Description                              = e.Description;
            dto.SerialNumberAttributeId                  = e.SerialNumberAttributeId;
            dto.LotAttributeId                           = e.LotAttributeId;
            dto.ReferenceId                              = e.ReferenceId;
            dto.Active                                   = e.Active;
            dto.IsPropertyNameRemoved                    = e.IsPropertyNameRemoved;
            dto.IsPropertyOrganizationIdRemoved          = e.IsPropertyOrganizationIdRemoved;
            dto.IsPropertyDescriptionRemoved             = e.IsPropertyDescriptionRemoved;
            dto.IsPropertySerialNumberAttributeIdRemoved = e.IsPropertySerialNumberAttributeIdRemoved;
            dto.IsPropertyLotAttributeIdRemoved          = e.IsPropertyLotAttributeIdRemoved;
            dto.IsPropertyReferenceIdRemoved             = e.IsPropertyReferenceIdRemoved;
            dto.IsPropertyActiveRemoved                  = e.IsPropertyActiveRemoved;
            var attributeUseEvents = new List <AttributeUseStateCreatedOrMergePatchedOrRemovedDto>();

            foreach (var ee in e.AttributeUseEvents)
            {
                AttributeUseStateCreatedOrMergePatchedOrRemovedDto eeDto = AttributeUseStateEventDtoConverter.ToAttributeUseStateEventDto(ee);
                attributeUseEvents.Add(eeDto);
            }
            dto.AttributeUseEvents = attributeUseEvents.ToArray();


            return(dto);
        }
 void IAttributeSetState.When(IAttributeSetStateMergePatched e)
 {
     throw new NotSupportedException();
 }