Exemplo n.º 1
0
        public static TDeletePickwave ToDeletePickwave <TDeletePickwave>(this IPickwaveState state)
            where TDeletePickwave : IDeletePickwave, new()
        {
            var cmd = new TDeletePickwave();

            cmd.PickwaveId = state.PickwaveId;
            cmd.Version    = ((IPickwaveStateProperties)state).Version;

            return(cmd);
        }
        public IPickwaveState Get(long?id)
        {
            IPickwaveState state = CurrentSession.Get <PickwaveState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPickwaveState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemplo n.º 3
0
        public static TCreatePickwave ToCreatePickwave <TCreatePickwave>(this IPickwaveState state)
            where TCreatePickwave : ICreatePickwave, new()
        {
            var cmd = new TCreatePickwave();

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

            cmd.PickwaveId  = state.PickwaveId;
            cmd.StatusId    = state.StatusId;
            cmd.Description = state.Description;
            cmd.Active      = ((IPickwaveStateProperties)state).Active;
            return(cmd);
        }
        public IPickwaveState Get(long?id, bool nullAllowed)
        {
            IPickwaveState state = CurrentSession.Get <PickwaveState> (id);

            if (!nullAllowed && state == null)
            {
                state = new PickwaveState();
                (state as PickwaveState).PickwaveId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPickwaveState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IPickwaveState> GetAsync(long?pickwaveId)
        {
            IPickwaveState state         = null;
            var            idObj         = pickwaveId;
            var            uriParameters = new PickwaveUriParameters();

            uriParameters.Id = idObj;

            var req = new PickwaveGetRequest(uriParameters);

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

            PickwaveProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToPickwaveState();
            return(state);
        }
        public void Save(IPickwaveState state)
        {
            IPickwaveState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
Exemplo n.º 7
0
        public static TMergePatchPickwave ToMergePatchPickwave <TMergePatchPickwave>(this IPickwaveState state)
            where TMergePatchPickwave : IMergePatchPickwave, new()
        {
            var cmd = new TMergePatchPickwave();

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

            cmd.PickwaveId  = state.PickwaveId;
            cmd.StatusId    = state.StatusId;
            cmd.Description = state.Description;
            cmd.Active      = ((IPickwaveStateProperties)state).Active;

            if (state.StatusId == null)
            {
                cmd.IsPropertyStatusIdRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
Exemplo n.º 8
0
        protected bool IsRepeatedCommand(IPickwaveCommand command, IEventStoreAggregateId eventStoreAggregateId, IPickwaveState state)
        {
            bool repeated = false;

            if (((IPickwaveStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IPickwaveEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Exemplo n.º 9
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IPickwaveAggregate aggregate, IPickwaveState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IPickwaveStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IPickwaveAggregate, IPickwaveState>(aggregate, state, aggregate.Changes));
     }
 }
Exemplo n.º 10
0
 public abstract IPickwaveAggregate GetPickwaveAggregate(IPickwaveState state);
Exemplo n.º 11
0
 public PickwaveStateDtoWrapper(IPickwaveState state)
 {
     this._state = state;
 }
Exemplo n.º 12
0
 public PickwaveStateDtoWrapper()
 {
     this._state = new PickwaveState();
 }
Exemplo n.º 13
0
 public override IPickwaveAggregate GetPickwaveAggregate(IPickwaveState state)
 {
     return(new PickwaveAggregate(state));
 }
Exemplo n.º 14
0
 public PickwaveAggregate(IPickwaveState state)
 {
     _state = state;
 }
Exemplo n.º 15
0
        public static IPickwaveCommand ToCreateOrMergePatchPickwave <TCreatePickwave, TMergePatchPickwave>(this IPickwaveState state)
            where TCreatePickwave : ICreatePickwave, new()
            where TMergePatchPickwave : IMergePatchPickwave, new()
        {
            bool bUnsaved = ((IPickwaveState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreatePickwave <TCreatePickwave>());
            }
            else
            {
                return(state.ToMergePatchPickwave <TMergePatchPickwave>());
            }
        }