public IAttributeUseMvoState Get(AttributeSetAttributeUseId id)
        {
            IAttributeUseMvoState state = CurrentSession.Get <AttributeUseMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeUseMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemplo n.º 2
0
        public IAttributeUseMvoState Get(AttributeSetAttributeUseId id)
        {
            IAttributeUseMvoState state = CurrentSession.Get <AttributeUseMvoState> (id);

            if (state == null)
            {
                state = new AttributeUseMvoState();
                (state as AttributeUseMvoState).AttributeSetAttributeUseId = id;
            }
            return(state);
        }
Exemplo n.º 3
0
        public void Save(IAttributeUseMvoState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Exemplo n.º 4
0
        public IAttributeUseMvoState Get(AttributeSetAttributeUseId id, bool nullAllowed)
        {
            IAttributeUseMvoState state = CurrentSession.Get <AttributeUseMvoState> (id);

            if (!nullAllowed && state == null)
            {
                state = new AttributeUseMvoState();
                (state as AttributeUseMvoState).AttributeSetAttributeUseId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeUseMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IAttributeUseMvoState> GetAsync(AttributeSetAttributeUseId attributeSetAttributeUseId)
        {
            IAttributeUseMvoState state = null;
            var idObj         = AttributeUseMvoProxyUtils.ToIdString(attributeSetAttributeUseId);
            var uriParameters = new AttributeUseMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new AttributeUseMvoGetRequest(uriParameters);

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

            AttributeUseMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = resp.Content;
            return(state);
        }
        public void Save(IAttributeUseMvoState state)
        {
            IAttributeUseMvoState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
 public override IAttributeUseMvoAggregate GetAttributeUseMvoAggregate(IAttributeUseMvoState state)
 {
     return(new AttributeUseMvoAggregate(state));
 }
Exemplo n.º 8
0
        public static IAttributeUseMvoCommand ToCreateOrMergePatchAttributeUseMvo <TCreateAttributeUseMvo, TMergePatchAttributeUseMvo>(this IAttributeUseMvoState state)
            where TCreateAttributeUseMvo : ICreateAttributeUseMvo, new()
            where TMergePatchAttributeUseMvo : IMergePatchAttributeUseMvo, new()
        {
            bool bUnsaved = ((IAttributeUseMvoState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAttributeUseMvo <TCreateAttributeUseMvo>());
            }
            else
            {
                return(state.ToMergePatchAttributeUseMvo <TMergePatchAttributeUseMvo>());
            }
        }
Exemplo n.º 9
0
 public AttributeUseMvoAggregate(IAttributeUseMvoState state)
 {
     _state = state;
 }
Exemplo n.º 10
0
        public static TMergePatchAttributeUseMvo ToMergePatchAttributeUseMvo <TMergePatchAttributeUseMvo>(this IAttributeUseMvoState state)
            where TMergePatchAttributeUseMvo : IMergePatchAttributeUseMvo, new()
        {
            var cmd = new TMergePatchAttributeUseMvo();

            cmd.AttributeSetVersion = ((IAttributeUseMvoStateProperties)state).AttributeSetVersion;

            cmd.AttributeSetAttributeUseId = state.AttributeSetAttributeUseId;
            cmd.SequenceNumber             = state.SequenceNumber;
            cmd.Version = ((IAttributeUseMvoStateProperties)state).Version;
            cmd.Active  = ((IAttributeUseMvoStateProperties)state).Active;
            cmd.AttributeSetAttributeSetName       = state.AttributeSetAttributeSetName;
            cmd.AttributeSetOrganizationId         = state.AttributeSetOrganizationId;
            cmd.AttributeSetDescription            = state.AttributeSetDescription;
            cmd.AttributeSetReferenceId            = state.AttributeSetReferenceId;
            cmd.AttributeSetIsInstanceAttributeSet = state.AttributeSetIsInstanceAttributeSet;
            cmd.AttributeSetIsMandatory            = state.AttributeSetIsMandatory;
            cmd.AttributeSetCreatedBy = state.AttributeSetCreatedBy;
            cmd.AttributeSetCreatedAt = state.AttributeSetCreatedAt;
            cmd.AttributeSetUpdatedBy = state.AttributeSetUpdatedBy;
            cmd.AttributeSetUpdatedAt = state.AttributeSetUpdatedAt;
            cmd.AttributeSetActive    = state.AttributeSetActive;
            cmd.AttributeSetDeleted   = state.AttributeSetDeleted;

            if (state.AttributeSetAttributeSetName == null)
            {
                cmd.IsPropertyAttributeSetAttributeSetNameRemoved = true;
            }
            if (state.AttributeSetOrganizationId == null)
            {
                cmd.IsPropertyAttributeSetOrganizationIdRemoved = true;
            }
            if (state.AttributeSetDescription == null)
            {
                cmd.IsPropertyAttributeSetDescriptionRemoved = true;
            }
            if (state.AttributeSetReferenceId == null)
            {
                cmd.IsPropertyAttributeSetReferenceIdRemoved = true;
            }
            if (state.AttributeSetCreatedBy == null)
            {
                cmd.IsPropertyAttributeSetCreatedByRemoved = true;
            }
            if (state.AttributeSetUpdatedBy == null)
            {
                cmd.IsPropertyAttributeSetUpdatedByRemoved = true;
            }
            return(cmd);
        }
        protected bool IsRepeatedCommand(IAttributeUseMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeUseMvoState state)
        {
            bool repeated = false;

            if (((IAttributeUseMvoStateProperties)state).AttributeSetVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IAttributeUseMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Exemplo n.º 12
0
        public static TCreateAttributeUseMvo ToCreateAttributeUseMvo <TCreateAttributeUseMvo>(this IAttributeUseMvoState state)
            where TCreateAttributeUseMvo : ICreateAttributeUseMvo, new()
        {
            var cmd = new TCreateAttributeUseMvo();

            cmd.AttributeSetVersion = ((IAttributeUseMvoStateProperties)state).AttributeSetVersion;

            cmd.AttributeSetAttributeUseId = state.AttributeSetAttributeUseId;
            cmd.SequenceNumber             = state.SequenceNumber;
            cmd.Version = ((IAttributeUseMvoStateProperties)state).Version;
            cmd.Active  = ((IAttributeUseMvoStateProperties)state).Active;
            cmd.AttributeSetAttributeSetName       = state.AttributeSetAttributeSetName;
            cmd.AttributeSetOrganizationId         = state.AttributeSetOrganizationId;
            cmd.AttributeSetDescription            = state.AttributeSetDescription;
            cmd.AttributeSetReferenceId            = state.AttributeSetReferenceId;
            cmd.AttributeSetIsInstanceAttributeSet = state.AttributeSetIsInstanceAttributeSet;
            cmd.AttributeSetIsMandatory            = state.AttributeSetIsMandatory;
            cmd.AttributeSetCreatedBy = state.AttributeSetCreatedBy;
            cmd.AttributeSetCreatedAt = state.AttributeSetCreatedAt;
            cmd.AttributeSetUpdatedBy = state.AttributeSetUpdatedBy;
            cmd.AttributeSetUpdatedAt = state.AttributeSetUpdatedAt;
            cmd.AttributeSetActive    = state.AttributeSetActive;
            cmd.AttributeSetDeleted   = state.AttributeSetDeleted;
            return(cmd);
        }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAttributeUseMvoAggregate aggregate, IAttributeUseMvoState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeUseMvoStateProperties)state).AttributeSetVersion, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IAttributeUseMvoAggregate, IAttributeUseMvoState>(aggregate, state, aggregate.Changes));
     }
 }
 public abstract IAttributeUseMvoAggregate GetAttributeUseMvoAggregate(IAttributeUseMvoState state);
Exemplo n.º 15
0
        public static TDeleteAttributeUseMvo ToDeleteAttributeUseMvo <TDeleteAttributeUseMvo>(this IAttributeUseMvoState state)
            where TDeleteAttributeUseMvo : IDeleteAttributeUseMvo, new()
        {
            var cmd = new TDeleteAttributeUseMvo();

            cmd.AttributeSetAttributeUseId = state.AttributeSetAttributeUseId;
            cmd.AttributeSetVersion        = ((IAttributeUseMvoStateProperties)state).AttributeSetVersion;

            return(cmd);
        }
 public AttributeUseMvoStateDtoWrapper(IAttributeUseMvoState state)
 {
     this._state = state;
 }
 public AttributeUseMvoStateDtoWrapper()
 {
     this._state = new AttributeUseMvoState();
 }