Example #1
0
        public ILocatorTypeState Get(string id)
        {
            ILocatorTypeState state = CurrentSession.Get <LocatorTypeState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <ILocatorTypeState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public static TDeleteLocatorType ToDeleteLocatorType <TDeleteLocatorType>(this ILocatorTypeState state)
            where TDeleteLocatorType : IDeleteLocatorType, new()
        {
            var cmd = new TDeleteLocatorType();

            cmd.LocatorTypeId = state.LocatorTypeId;
            cmd.Version       = ((ILocatorTypeStateProperties)state).Version;

            return(cmd);
        }
        public static TCreateLocatorType ToCreateLocatorType <TCreateLocatorType>(this ILocatorTypeState state)
            where TCreateLocatorType : ICreateLocatorType, new()
        {
            var cmd = new TCreateLocatorType();

            cmd.Version = ((ILocatorTypeStateProperties)state).Version;

            cmd.LocatorTypeId = state.LocatorTypeId;
            cmd.Description   = state.Description;
            cmd.Active        = ((ILocatorTypeStateProperties)state).Active;
            return(cmd);
        }
        public ILocatorTypeState Get(string id, bool nullAllowed)
        {
            ILocatorTypeState state = CurrentSession.Get <LocatorTypeState> (id);

            if (!nullAllowed && state == null)
            {
                state = new LocatorTypeState();
                (state as LocatorTypeState).LocatorTypeId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <ILocatorTypeState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <ILocatorTypeState> GetAsync(string locatorTypeId)
        {
            ILocatorTypeState state = null;
            var idObj         = locatorTypeId;
            var uriParameters = new LocatorTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new LocatorTypeGetRequest(uriParameters);

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

            LocatorTypeProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToLocatorTypeState();
            return(state);
        }
        public void Save(ILocatorTypeState state)
        {
            ILocatorTypeState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
Example #7
0
 public LocatorTypeStateDtoWrapper(ILocatorTypeState state)
 {
     this._state = state;
 }
Example #8
0
 public LocatorTypeStateDtoWrapper()
 {
     this._state = new LocatorTypeState();
 }
Example #9
0
 public LocatorTypeAggregate(ILocatorTypeState state)
 {
     _state = state;
 }
Example #10
0
 public override ILocatorTypeAggregate GetLocatorTypeAggregate(ILocatorTypeState state)
 {
     return(new LocatorTypeAggregate(state));
 }
        public static TMergePatchLocatorType ToMergePatchLocatorType <TMergePatchLocatorType>(this ILocatorTypeState state)
            where TMergePatchLocatorType : IMergePatchLocatorType, new()
        {
            var cmd = new TMergePatchLocatorType();

            cmd.Version = ((ILocatorTypeStateProperties)state).Version;

            cmd.LocatorTypeId = state.LocatorTypeId;
            cmd.Description   = state.Description;
            cmd.Active        = ((ILocatorTypeStateProperties)state).Active;

            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
        public static ILocatorTypeCommand ToCreateOrMergePatchLocatorType <TCreateLocatorType, TMergePatchLocatorType>(this ILocatorTypeState state)
            where TCreateLocatorType : ICreateLocatorType, new()
            where TMergePatchLocatorType : IMergePatchLocatorType, new()
        {
            bool bUnsaved = ((ILocatorTypeState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateLocatorType <TCreateLocatorType>());
            }
            else
            {
                return(state.ToMergePatchLocatorType <TMergePatchLocatorType>());
            }
        }
Example #13
0
        protected bool IsRepeatedCommand(ILocatorTypeCommand command, IEventStoreAggregateId eventStoreAggregateId, ILocatorTypeState state)
        {
            bool repeated = false;

            if (((ILocatorTypeStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(ILocatorTypeEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Example #14
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, ILocatorTypeAggregate aggregate, ILocatorTypeState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((ILocatorTypeStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <ILocatorTypeAggregate, ILocatorTypeState>(aggregate, state, aggregate.Changes));
     }
 }
Example #15
0
 public abstract ILocatorTypeAggregate GetLocatorTypeAggregate(ILocatorTypeState state);