public IAttributeAliasState Get(AttributeAliasId id, bool nullAllowed)
        {
            IAttributeAliasState state = CurrentSession.Get <AttributeAliasState>(id);

            if (!nullAllowed && state == null)
            {
                state = new AttributeAliasState();
                (state as AttributeAliasState).AttributeAliasId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeAliasState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public void Delete(IAttributeAliasState state)
        {
            IAttributeAliasState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IAttributeAliasState>(state);
            }
            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Delete(s);
        }
Esempio n. 3
0
        public virtual void When(IAttributeStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.AttributeName = e.AttributeName;

            this.OrganizationId = e.OrganizationId;

            this.Description = e.Description;

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

            this.AttributeValueType = e.AttributeValueType;

            this.AttributeValueLength = e.AttributeValueLength;

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

            this.FieldName = e.FieldName;

            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;

            foreach (IAttributeValueStateCreated innerEvent in e.AttributeValueEvents)
            {
                IAttributeValueState innerState = this.AttributeValues.Get(innerEvent.GlobalId.Value, true);
                innerState.Mutate(innerEvent);
            }
            foreach (IAttributeAliasStateCreated innerEvent in e.AttributeAliasEvents)
            {
                IAttributeAliasState innerState = this.Aliases.Get(innerEvent.GlobalId.Code, true);
                innerState.Mutate(innerEvent);
            }
        }
        public static TCreateAttributeAlias ToCreateAttributeAlias <TCreateAttributeAlias>(this IAttributeAliasState state)
            where TCreateAttributeAlias : ICreateAttributeAlias, new()
        {
            var cmd = new TCreateAttributeAlias();

            cmd.Code        = state.Code;
            cmd.Name        = state.Name;
            cmd.Active      = ((IAttributeAliasStateProperties)state).Active;
            cmd.AttributeId = state.AttributeId;
            return(cmd);
        }
        public static TMergePatchAttributeAlias ToMergePatchAttributeAlias <TMergePatchAttributeAlias>(this IAttributeAliasState state)
            where TMergePatchAttributeAlias : IMergePatchAttributeAlias, new()
        {
            var cmd = new TMergePatchAttributeAlias();

            cmd.Code        = state.Code;
            cmd.Name        = state.Name;
            cmd.Active      = ((IAttributeAliasStateProperties)state).Active;
            cmd.AttributeId = state.AttributeId;

            if (state.Name == null)
            {
                cmd.IsPropertyNameRemoved = true;
            }
            return(cmd);
        }
        public static TRemoveAttributeAlias ToRemoveAttributeAlias <TRemoveAttributeAlias>(this IAttributeAliasState state)
            where TRemoveAttributeAlias : IRemoveAttributeAlias, new()
        {
            var cmd = new TRemoveAttributeAlias();

            cmd.Code = state.Code;
            return(cmd);
        }
        public static IAttributeAliasCommand ToCreateOrMergePatchAttributeAlias <TCreateAttributeAlias, TMergePatchAttributeAlias>(this IAttributeAliasState state)
            where TCreateAttributeAlias : ICreateAttributeAlias, new()
            where TMergePatchAttributeAlias : IMergePatchAttributeAlias, new()
        {
            bool bUnsaved = ((IAttributeAliasState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAttributeAlias <TCreateAttributeAlias>());
            }
            else
            {
                return(state.ToMergePatchAttributeAlias <TMergePatchAttributeAlias>());
            }
        }
Esempio n. 8
0
 public void AddToSave(IAttributeAliasState state)
 {
     throw new NotSupportedException();
 }
Esempio n. 9
0
 public AttributeAliasStateDtoWrapper(IAttributeAliasState state)
 {
     this._state = state;
 }
Esempio n. 10
0
 public AttributeAliasStateDtoWrapper()
 {
     this._state = new AttributeAliasState();
 }
Esempio n. 11
0
 public virtual void Remove(IAttributeAliasState state)
 {
     this._removedAttributeAliasStates.Add(state.GlobalId, state);
 }
Esempio n. 12
0
 public virtual void AddToSave(IAttributeAliasState state)
 {
     this._loadedAttributeAliasStates[state.GlobalId] = state;
 }
Esempio n. 13
0
        public virtual void When(IAttributeStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.AttributeName == null)
            {
                if (e.IsPropertyAttributeNameRemoved)
                {
                    this.AttributeName = default(string);
                }
            }
            else
            {
                this.AttributeName = e.AttributeName;
            }

            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.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.AttributeValueType == null)
            {
                if (e.IsPropertyAttributeValueTypeRemoved)
                {
                    this.AttributeValueType = default(string);
                }
            }
            else
            {
                this.AttributeValueType = e.AttributeValueType;
            }

            if (e.AttributeValueLength == null)
            {
                if (e.IsPropertyAttributeValueLengthRemoved)
                {
                    this.AttributeValueLength = default(int?);
                }
            }
            else
            {
                this.AttributeValueLength = e.AttributeValueLength;
            }

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

            if (e.FieldName == null)
            {
                if (e.IsPropertyFieldNameRemoved)
                {
                    this.FieldName = default(string);
                }
            }
            else
            {
                this.FieldName = e.FieldName;
            }

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

            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 (IAttributeValueEvent innerEvent in e.AttributeValueEvents)
            {
                IAttributeValueState innerState = this.AttributeValues.Get(innerEvent.GlobalId.Value);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IAttributeValueStateRemoved;
                if (removed != null)
                {
                    this.AttributeValues.Remove(innerState);
                }
            }

            foreach (IAttributeAliasEvent innerEvent in e.AttributeAliasEvents)
            {
                IAttributeAliasState innerState = this.Aliases.Get(innerEvent.GlobalId.Code);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IAttributeAliasStateRemoved;
                if (removed != null)
                {
                    this.Aliases.Remove(innerState);
                }
            }
        }