public IAttributeAliasMvoState Get(AttributeAliasId id)
        {
            IAttributeAliasMvoState state = CurrentSession.Get <AttributeAliasMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeAliasMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
示例#2
0
        public IAttributeAliasMvoState Get(AttributeAliasId id, bool nullAllowed)
        {
            IAttributeAliasMvoState state = CurrentSession.Get <AttributeAliasMvoState> (id);

            if (!nullAllowed && state == null)
            {
                state = new AttributeAliasMvoState();
                (state as AttributeAliasMvoState).AttributeAliasId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeAliasMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IAttributeAliasMvoState> GetAsync(AttributeAliasId attributeAliasId)
        {
            IAttributeAliasMvoState state = null;
            var idObj         = AttributeAliasMvoProxyUtils.ToIdString(attributeAliasId);
            var uriParameters = new AttributeAliasMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new AttributeAliasMvoGetRequest(uriParameters);

            var resp = await _ramlClient.AttributeAliasMvo.Get(req);

            AttributeAliasMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToAttributeAliasMvoState();
            return(state);
        }
示例#4
0
        public void Save(IAttributeAliasMvoState state)
        {
            IAttributeAliasMvoState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IAttributeAliasMvoState>(state);
            }
            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
        public static TMergePatchAttributeAliasMvo ToMergePatchAttributeAliasMvo <TMergePatchAttributeAliasMvo>(this IAttributeAliasMvoState state)
            where TMergePatchAttributeAliasMvo : IMergePatchAttributeAliasMvo, new()
        {
            var cmd = new TMergePatchAttributeAliasMvo();

            cmd.AttributeVersion = ((IAttributeAliasMvoStateProperties)state).AttributeVersion;

            cmd.AttributeAliasId              = state.AttributeAliasId;
            cmd.Name                          = state.Name;
            cmd.Version                       = ((IAttributeAliasMvoStateProperties)state).Version;
            cmd.Active                        = ((IAttributeAliasMvoStateProperties)state).Active;
            cmd.AttributeAttributeName        = state.AttributeAttributeName;
            cmd.AttributeOrganizationId       = state.AttributeOrganizationId;
            cmd.AttributeDescription          = state.AttributeDescription;
            cmd.AttributeIsMandatory          = state.AttributeIsMandatory;
            cmd.AttributeAttributeValueType   = state.AttributeAttributeValueType;
            cmd.AttributeAttributeValueLength = state.AttributeAttributeValueLength;
            cmd.AttributeIsList               = state.AttributeIsList;
            cmd.AttributeFieldName            = state.AttributeFieldName;
            cmd.AttributeReferenceId          = state.AttributeReferenceId;
            cmd.AttributeCreatedBy            = state.AttributeCreatedBy;
            cmd.AttributeCreatedAt            = state.AttributeCreatedAt;
            cmd.AttributeUpdatedBy            = state.AttributeUpdatedBy;
            cmd.AttributeUpdatedAt            = state.AttributeUpdatedAt;
            cmd.AttributeActive               = state.AttributeActive;
            cmd.AttributeDeleted              = state.AttributeDeleted;

            if (state.Name == null)
            {
                cmd.IsPropertyNameRemoved = true;
            }
            if (state.AttributeAttributeName == null)
            {
                cmd.IsPropertyAttributeAttributeNameRemoved = true;
            }
            if (state.AttributeOrganizationId == null)
            {
                cmd.IsPropertyAttributeOrganizationIdRemoved = true;
            }
            if (state.AttributeDescription == null)
            {
                cmd.IsPropertyAttributeDescriptionRemoved = true;
            }
            if (state.AttributeAttributeValueType == null)
            {
                cmd.IsPropertyAttributeAttributeValueTypeRemoved = true;
            }
            if (state.AttributeAttributeValueLength == null)
            {
                cmd.IsPropertyAttributeAttributeValueLengthRemoved = true;
            }
            if (state.AttributeFieldName == null)
            {
                cmd.IsPropertyAttributeFieldNameRemoved = true;
            }
            if (state.AttributeReferenceId == null)
            {
                cmd.IsPropertyAttributeReferenceIdRemoved = true;
            }
            if (state.AttributeCreatedBy == null)
            {
                cmd.IsPropertyAttributeCreatedByRemoved = true;
            }
            if (state.AttributeUpdatedBy == null)
            {
                cmd.IsPropertyAttributeUpdatedByRemoved = true;
            }
            return(cmd);
        }
        public static TDeleteAttributeAliasMvo ToDeleteAttributeAliasMvo <TDeleteAttributeAliasMvo>(this IAttributeAliasMvoState state)
            where TDeleteAttributeAliasMvo : IDeleteAttributeAliasMvo, new()
        {
            var cmd = new TDeleteAttributeAliasMvo();

            cmd.AttributeAliasId = state.AttributeAliasId;
            cmd.AttributeVersion = ((IAttributeAliasMvoStateProperties)state).AttributeVersion;

            return(cmd);
        }
        public static IAttributeAliasMvoCommand ToCreateOrMergePatchAttributeAliasMvo <TCreateAttributeAliasMvo, TMergePatchAttributeAliasMvo>(this IAttributeAliasMvoState state)
            where TCreateAttributeAliasMvo : ICreateAttributeAliasMvo, new()
            where TMergePatchAttributeAliasMvo : IMergePatchAttributeAliasMvo, new()
        {
            bool bUnsaved = ((IAttributeAliasMvoState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAttributeAliasMvo <TCreateAttributeAliasMvo>());
            }
            else
            {
                return(state.ToMergePatchAttributeAliasMvo <TMergePatchAttributeAliasMvo>());
            }
        }
        public static TCreateAttributeAliasMvo ToCreateAttributeAliasMvo <TCreateAttributeAliasMvo>(this IAttributeAliasMvoState state)
            where TCreateAttributeAliasMvo : ICreateAttributeAliasMvo, new()
        {
            var cmd = new TCreateAttributeAliasMvo();

            cmd.AttributeVersion = ((IAttributeAliasMvoStateProperties)state).AttributeVersion;

            cmd.AttributeAliasId              = state.AttributeAliasId;
            cmd.Name                          = state.Name;
            cmd.Version                       = ((IAttributeAliasMvoStateProperties)state).Version;
            cmd.Active                        = ((IAttributeAliasMvoStateProperties)state).Active;
            cmd.AttributeAttributeName        = state.AttributeAttributeName;
            cmd.AttributeOrganizationId       = state.AttributeOrganizationId;
            cmd.AttributeDescription          = state.AttributeDescription;
            cmd.AttributeIsMandatory          = state.AttributeIsMandatory;
            cmd.AttributeAttributeValueType   = state.AttributeAttributeValueType;
            cmd.AttributeAttributeValueLength = state.AttributeAttributeValueLength;
            cmd.AttributeIsList               = state.AttributeIsList;
            cmd.AttributeFieldName            = state.AttributeFieldName;
            cmd.AttributeReferenceId          = state.AttributeReferenceId;
            cmd.AttributeCreatedBy            = state.AttributeCreatedBy;
            cmd.AttributeCreatedAt            = state.AttributeCreatedAt;
            cmd.AttributeUpdatedBy            = state.AttributeUpdatedBy;
            cmd.AttributeUpdatedAt            = state.AttributeUpdatedAt;
            cmd.AttributeActive               = state.AttributeActive;
            cmd.AttributeDeleted              = state.AttributeDeleted;
            return(cmd);
        }
示例#9
0
 public override IAttributeAliasMvoAggregate GetAttributeAliasMvoAggregate(IAttributeAliasMvoState state)
 {
     return(new AttributeAliasMvoAggregate(state));
 }
        protected bool IsRepeatedCommand(IAttributeAliasMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeAliasMvoState state)
        {
            bool repeated = false;

            if (((IAttributeAliasMvoStateProperties)state).AttributeVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IAttributeAliasMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAttributeAliasMvoAggregate aggregate, IAttributeAliasMvoState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeAliasMvoStateProperties)state).AttributeVersion, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IAttributeAliasMvoAggregate, IAttributeAliasMvoState>(aggregate, state, aggregate.Changes));
     }
 }
 public abstract IAttributeAliasMvoAggregate GetAttributeAliasMvoAggregate(IAttributeAliasMvoState state);
 public AttributeAliasMvoStateDtoWrapper(IAttributeAliasMvoState state)
 {
     this._state = state;
 }
 public AttributeAliasMvoStateDtoWrapper()
 {
     this._state = new AttributeAliasMvoState();
 }
示例#15
0
 public AttributeAliasMvoAggregate(IAttributeAliasMvoState state)
 {
     _state = state;
 }