Exemple #1
0
        public IAttributeValueMvoState Get(AttributeValueId id)
        {
            IAttributeValueMvoState state = CurrentSession.Get <AttributeValueMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeValueMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemple #2
0
        public void Save(IAttributeValueMvoState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Exemple #3
0
        public IAttributeValueMvoState Get(AttributeValueId id)
        {
            IAttributeValueMvoState state = CurrentSession.Get <AttributeValueMvoState> (id);

            if (state == null)
            {
                state = new AttributeValueMvoState();
                (state as AttributeValueMvoState).AttributeValueId = id;
            }
            return(state);
        }
Exemple #4
0
        public IAttributeValueMvoState Get(AttributeValueId id, bool nullAllowed)
        {
            IAttributeValueMvoState state = CurrentSession.Get <AttributeValueMvoState> (id);

            if (!nullAllowed && state == null)
            {
                state = new AttributeValueMvoState();
                (state as AttributeValueMvoState).AttributeValueId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeValueMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IAttributeValueMvoState> GetAsync(AttributeValueId attributeValueId)
        {
            IAttributeValueMvoState state = null;
            var idObj         = AttributeValueMvoProxyUtils.ToIdString(attributeValueId);
            var uriParameters = new AttributeValueMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new AttributeValueMvoGetRequest(uriParameters);

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

            AttributeValueMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToAttributeValueMvoState();
            return(state);
        }
Exemple #6
0
        public void Save(IAttributeValueMvoState state)
        {
            IAttributeValueMvoState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
        public static IAttributeValueMvoCommand ToCreateOrMergePatchAttributeValueMvo <TCreateAttributeValueMvo, TMergePatchAttributeValueMvo>(this IAttributeValueMvoState state)
            where TCreateAttributeValueMvo : ICreateAttributeValueMvo, new()
            where TMergePatchAttributeValueMvo : IMergePatchAttributeValueMvo, new()
        {
            bool bUnsaved = ((IAttributeValueMvoState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAttributeValueMvo <TCreateAttributeValueMvo>());
            }
            else
            {
                return(state.ToMergePatchAttributeValueMvo <TMergePatchAttributeValueMvo>());
            }
        }
        public static TCreateAttributeValueMvo ToCreateAttributeValueMvo <TCreateAttributeValueMvo>(this IAttributeValueMvoState state)
            where TCreateAttributeValueMvo : ICreateAttributeValueMvo, new()
        {
            var cmd = new TCreateAttributeValueMvo();

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

            cmd.AttributeValueId              = state.AttributeValueId;
            cmd.AttributeValueName            = state.AttributeValueName;
            cmd.Description                   = state.Description;
            cmd.ReferenceId                   = state.ReferenceId;
            cmd.Version                       = ((IAttributeValueMvoStateProperties)state).Version;
            cmd.Active                        = ((IAttributeValueMvoStateProperties)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);
        }
Exemple #9
0
 public AttributeValueMvoStateDtoWrapper(IAttributeValueMvoState state)
 {
     this._state = state;
 }
Exemple #10
0
 public AttributeValueMvoStateDtoWrapper()
 {
     this._state = new AttributeValueMvoState();
 }
 public AttributeValueMvoAggregate(IAttributeValueMvoState state)
 {
     _state = state;
 }
 public override IAttributeValueMvoAggregate GetAttributeValueMvoAggregate(IAttributeValueMvoState state)
 {
     return(new AttributeValueMvoAggregate(state));
 }
Exemple #13
0
        protected bool IsRepeatedCommand(IAttributeValueMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeValueMvoState state)
        {
            bool repeated = false;

            if (((IAttributeValueMvoStateProperties)state).AttributeVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.FindLastEvent(typeof(IAttributeValueMvoStateEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Exemple #14
0
 public abstract IAttributeValueMvoAggregate GetAttributeValueMvoAggregate(IAttributeValueMvoState state);
        public static TDeleteAttributeValueMvo ToDeleteAttributeValueMvo <TDeleteAttributeValueMvo>(this IAttributeValueMvoState state)
            where TDeleteAttributeValueMvo : IDeleteAttributeValueMvo, new()
        {
            var cmd = new TDeleteAttributeValueMvo();

            cmd.AttributeValueId = state.AttributeValueId;
            cmd.AttributeVersion = ((IAttributeValueMvoStateProperties)state).AttributeVersion;

            return(cmd);
        }
        public static TMergePatchAttributeValueMvo ToMergePatchAttributeValueMvo <TMergePatchAttributeValueMvo>(this IAttributeValueMvoState state)
            where TMergePatchAttributeValueMvo : IMergePatchAttributeValueMvo, new()
        {
            var cmd = new TMergePatchAttributeValueMvo();

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

            cmd.AttributeValueId              = state.AttributeValueId;
            cmd.AttributeValueName            = state.AttributeValueName;
            cmd.Description                   = state.Description;
            cmd.ReferenceId                   = state.ReferenceId;
            cmd.Version                       = ((IAttributeValueMvoStateProperties)state).Version;
            cmd.Active                        = ((IAttributeValueMvoStateProperties)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.AttributeValueName == null)
            {
                cmd.IsPropertyAttributeValueNameRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.ReferenceId == null)
            {
                cmd.IsPropertyReferenceIdRemoved = 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);
        }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAttributeValueMvoAggregate aggregate, IAttributeValueMvoState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeValueMvoStateProperties)state).AttributeVersion, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IAttributeValueMvoAggregate, IAttributeValueMvoState>(aggregate, state, aggregate.Changes));
     }
 }