public static TMergePatchLocator ToMergePatchLocator <TMergePatchLocator>(this ILocatorState state)
            where TMergePatchLocator : IMergePatchLocator, new()
        {
            var cmd = new TMergePatchLocator();

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

            cmd.LocatorId       = state.LocatorId;
            cmd.WarehouseId     = state.WarehouseId;
            cmd.ParentLocatorId = state.ParentLocatorId;
            cmd.LocatorType     = state.LocatorType;
            cmd.PriorityNumber  = state.PriorityNumber;
            cmd.IsDefault       = state.IsDefault;
            cmd.X             = state.X;
            cmd.Y             = state.Y;
            cmd.Z             = state.Z;
            cmd.Description   = state.Description;
            cmd.LocatorTypeId = state.LocatorTypeId;
            cmd.Active        = ((ILocatorStateProperties)state).Active;

            if (state.WarehouseId == null)
            {
                cmd.IsPropertyWarehouseIdRemoved = true;
            }
            if (state.ParentLocatorId == null)
            {
                cmd.IsPropertyParentLocatorIdRemoved = true;
            }
            if (state.LocatorType == null)
            {
                cmd.IsPropertyLocatorTypeRemoved = true;
            }
            if (state.PriorityNumber == null)
            {
                cmd.IsPropertyPriorityNumberRemoved = true;
            }
            if (state.X == null)
            {
                cmd.IsPropertyXRemoved = true;
            }
            if (state.Y == null)
            {
                cmd.IsPropertyYRemoved = true;
            }
            if (state.Z == null)
            {
                cmd.IsPropertyZRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.LocatorTypeId == null)
            {
                cmd.IsPropertyLocatorTypeIdRemoved = true;
            }
            return(cmd);
        }
        public ILocatorState Get(string id)
        {
            ILocatorState state = CurrentSession.Get <LocatorState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <ILocatorState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public static TDeleteLocator ToDeleteLocator <TDeleteLocator>(this ILocatorState state)
            where TDeleteLocator : IDeleteLocator, new()
        {
            var cmd = new TDeleteLocator();

            cmd.LocatorId = state.LocatorId;
            cmd.Version   = ((ILocatorStateProperties)state).Version;

            return(cmd);
        }
        public void Save(ILocatorState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
        public ILocatorState Get(string id)
        {
            ILocatorState state = CurrentSession.Get <LocatorState> (id);

            if (state == null)
            {
                state = new LocatorState();
                (state as LocatorState).LocatorId = id;
            }
            return(state);
        }
예제 #6
0
        public ILocatorState Get(string id, bool nullAllowed)
        {
            ILocatorState state = CurrentSession.Get <LocatorState> (id);

            if (!nullAllowed && state == null)
            {
                state = new LocatorState();
                (state as LocatorState).LocatorId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <ILocatorState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <ILocatorState> GetAsync(string locatorId)
        {
            ILocatorState state         = null;
            var           idObj         = locatorId;
            var           uriParameters = new LocatorUriParameters();

            uriParameters.Id = idObj;

            var req = new LocatorGetRequest(uriParameters);

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

            LocatorProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToLocatorState();
            return(state);
        }
        public void Save(ILocatorState state)
        {
            ILocatorState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
        public static TCreateLocator ToCreateLocator <TCreateLocator>(this ILocatorState state)
            where TCreateLocator : ICreateLocator, new()
        {
            var cmd = new TCreateLocator();

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

            cmd.LocatorId       = state.LocatorId;
            cmd.WarehouseId     = state.WarehouseId;
            cmd.ParentLocatorId = state.ParentLocatorId;
            cmd.LocatorType     = state.LocatorType;
            cmd.PriorityNumber  = state.PriorityNumber;
            cmd.IsDefault       = state.IsDefault;
            cmd.X      = state.X;
            cmd.Y      = state.Y;
            cmd.Z      = state.Z;
            cmd.Active = ((ILocatorStateProperties)state).Active;
            return(cmd);
        }
예제 #10
0
        public static ILocatorCommand ToCreateOrMergePatchLocator <TCreateLocator, TMergePatchLocator>(this ILocatorState state)
            where TCreateLocator : ICreateLocator, new()
            where TMergePatchLocator : IMergePatchLocator, new()
        {
            bool bUnsaved = ((ILocatorState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateLocator <TCreateLocator>());
            }
            else
            {
                return(state.ToMergePatchLocator <TMergePatchLocator>());
            }
        }
예제 #11
0
 public LocatorStateDtoWrapper(ILocatorState state)
 {
     this._state = state;
 }
예제 #12
0
 public LocatorStateDtoWrapper()
 {
     this._state = new LocatorState();
 }
예제 #13
0
 public override ILocatorAggregate GetLocatorAggregate(ILocatorState state)
 {
     return(new LocatorAggregate(state));
 }
예제 #14
0
 public abstract ILocatorAggregate GetLocatorAggregate(ILocatorState state);
예제 #15
0
 public LocatorAggregate(ILocatorState state)
 {
     _state = state;
 }
예제 #16
0
        protected bool IsRepeatedCommand(ILocatorCommand command, IEventStoreAggregateId eventStoreAggregateId, ILocatorState state)
        {
            bool repeated = false;

            if (((ILocatorStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.FindLastEvent(typeof(ILocatorStateEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
예제 #17
0
 public LocatorTreeNode(ILocatorState state, ILocatorTreeRepository repository)
 {
     this._state      = state;
     this._repository = repository;
 }
예제 #18
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, ILocatorAggregate aggregate, ILocatorState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((ILocatorStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <ILocatorAggregate, ILocatorState>(aggregate, state, aggregate.Changes));
     }
 }