public static TDeleteAudience ToDeleteAudience <TDeleteAudience>(this IAudienceState state)
            where TDeleteAudience : IDeleteAudience, new()
        {
            var cmd = new TDeleteAudience();

            cmd.ClientId = state.ClientId;
            cmd.Version  = ((IAudienceStateProperties)state).Version;

            return(cmd);
        }
        public IAudienceState Get(string id)
        {
            IAudienceState state = CurrentSession.Get <AudienceState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAudienceState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemplo n.º 3
0
        public void Save(IAudienceState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Exemplo n.º 4
0
        public IAudienceState Get(string id)
        {
            IAudienceState state = CurrentSession.Get <AudienceState> (id);

            if (state == null)
            {
                state = new AudienceState();
                (state as AudienceState).ClientId = id;
            }
            return(state);
        }
        public static TCreateAudience ToCreateAudience <TCreateAudience>(this IAudienceState state)
            where TCreateAudience : ICreateAudience, new()
        {
            var cmd = new TCreateAudience();

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

            cmd.ClientId     = state.ClientId;
            cmd.Name         = state.Name;
            cmd.Base64Secret = state.Base64Secret;
            cmd.Active       = ((IAudienceStateProperties)state).Active;
            return(cmd);
        }
        public IAudienceState Get(string id, bool nullAllowed)
        {
            IAudienceState state = CurrentSession.Get <AudienceState> (id);

            if (!nullAllowed && state == null)
            {
                state = new AudienceState();
                (state as AudienceState).ClientId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAudienceState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IAudienceState> GetAsync(string clientId)
        {
            IAudienceState state         = null;
            var            idObj         = clientId;
            var            uriParameters = new AudienceUriParameters();

            uriParameters.Id = idObj;

            var req = new AudienceGetRequest(uriParameters);

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

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

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
        public static TMergePatchAudience ToMergePatchAudience <TMergePatchAudience>(this IAudienceState state)
            where TMergePatchAudience : IMergePatchAudience, new()
        {
            var cmd = new TMergePatchAudience();

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

            cmd.ClientId     = state.ClientId;
            cmd.Name         = state.Name;
            cmd.Base64Secret = state.Base64Secret;
            cmd.Active       = ((IAudienceStateProperties)state).Active;

            if (state.Name == null)
            {
                cmd.IsPropertyNameRemoved = true;
            }
            if (state.Base64Secret == null)
            {
                cmd.IsPropertyBase64SecretRemoved = true;
            }
            return(cmd);
        }
Exemplo n.º 10
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAudienceAggregate aggregate, IAudienceState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IAudienceStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IAudienceAggregate, IAudienceState>(aggregate, state, aggregate.Changes));
     }
 }
Exemplo n.º 11
0
 public AudienceStateDtoWrapper(IAudienceState state)
 {
     this._state = state;
 }
Exemplo n.º 12
0
 public override IAudienceAggregate GetAudienceAggregate(IAudienceState state)
 {
     return(new AudienceAggregate(state));
 }
Exemplo n.º 13
0
 public AudienceAggregate(IAudienceState state)
 {
     _state = state;
 }
 public abstract IAudienceAggregate GetAudienceAggregate(IAudienceState state);
Exemplo n.º 15
0
        public static IAudienceCommand ToCreateOrMergePatchAudience <TCreateAudience, TMergePatchAudience>(this IAudienceState state)
            where TCreateAudience : ICreateAudience, new()
            where TMergePatchAudience : IMergePatchAudience, new()
        {
            bool bUnsaved = ((IAudienceState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAudience <TCreateAudience>());
            }
            else
            {
                return(state.ToMergePatchAudience <TMergePatchAudience>());
            }
        }
        protected bool IsRepeatedCommand(IAudienceCommand command, IEventStoreAggregateId eventStoreAggregateId, IAudienceState state)
        {
            bool repeated = false;

            if (((IAudienceStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.FindLastEvent(typeof(IAudienceStateEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Exemplo n.º 17
0
 public AudienceStateDtoWrapper()
 {
     this._state = new AudienceState();
 }