public static TDeletePermission ToDeletePermission <TDeletePermission>(this IPermissionState state)
            where TDeletePermission : IDeletePermission, new()
        {
            var cmd = new TDeletePermission();

            cmd.PermissionId = state.PermissionId;
            cmd.Version      = ((IPermissionStateProperties)state).Version;

            return(cmd);
        }
Example #2
0
        public IPermissionState Get(string id)
        {
            IPermissionState state = CurrentSession.Get <PermissionState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPermissionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public IPermissionState Get(string id)
        {
            IPermissionState state = CurrentSession.Get <PermissionState> (id);

            if (state == null)
            {
                state = new PermissionState();
                (state as PermissionState).PermissionId = id;
            }
            return(state);
        }
        public void Save(IPermissionState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
        public static TCreatePermission ToCreatePermission <TCreatePermission>(this IPermissionState state)
            where TCreatePermission : ICreatePermission, new()
        {
            var cmd = new TCreatePermission();

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

            cmd.PermissionId       = state.PermissionId;
            cmd.Name               = state.Name;
            cmd.ParentPermissionId = state.ParentPermissionId;
            cmd.Description        = state.Description;
            cmd.Active             = ((IPermissionStateProperties)state).Active;
            return(cmd);
        }
        public IPermissionState Get(string id, bool nullAllowed)
        {
            IPermissionState state = CurrentSession.Get <PermissionState> (id);

            if (!nullAllowed && state == null)
            {
                state = new PermissionState();
                (state as PermissionState).PermissionId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPermissionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IPermissionState> GetAsync(string permissionId)
        {
            IPermissionState state = null;
            var idObj         = permissionId;
            var uriParameters = new PermissionUriParameters();

            uriParameters.Id = idObj;

            var req = new PermissionGetRequest(uriParameters);

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

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

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Example #9
0
 public PermissionAggregate(IPermissionState state)
 {
     _state = state;
 }
        public static TMergePatchPermission ToMergePatchPermission <TMergePatchPermission>(this IPermissionState state)
            where TMergePatchPermission : IMergePatchPermission, new()
        {
            var cmd = new TMergePatchPermission();

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

            cmd.PermissionId       = state.PermissionId;
            cmd.Name               = state.Name;
            cmd.ParentPermissionId = state.ParentPermissionId;
            cmd.Description        = state.Description;
            cmd.Active             = ((IPermissionStateProperties)state).Active;

            if (state.Name == null)
            {
                cmd.IsPropertyNameRemoved = true;
            }
            if (state.ParentPermissionId == null)
            {
                cmd.IsPropertyParentPermissionIdRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
        public static IPermissionCommand ToCreateOrMergePatchPermission <TCreatePermission, TMergePatchPermission>(this IPermissionState state)
            where TCreatePermission : ICreatePermission, new()
            where TMergePatchPermission : IMergePatchPermission, new()
        {
            bool bUnsaved = ((IPermissionState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreatePermission <TCreatePermission>());
            }
            else
            {
                return(state.ToMergePatchPermission <TMergePatchPermission>());
            }
        }
Example #12
0
 public PermissionStateDtoWrapper()
 {
     this._state = new PermissionState();
 }
Example #13
0
 public PermissionStateDtoWrapper(IPermissionState state)
 {
     this._state = state;
 }
Example #14
0
 public PermissionTreeNode(IPermissionState state, IPermissionTreeRepository repository)
 {
     this._state      = state;
     this._repository = repository;
 }
Example #15
0
        protected bool IsRepeatedCommand(IPermissionCommand command, IEventStoreAggregateId eventStoreAggregateId, IPermissionState state)
        {
            bool repeated = false;

            if (((IPermissionStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.FindLastEvent(typeof(IPermissionStateEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Example #16
0
 public abstract IPermissionAggregate GetPermissionAggregate(IPermissionState state);
 public override IPermissionAggregate GetPermissionAggregate(IPermissionState state)
 {
     return(new PermissionAggregate(state));
 }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IPermissionAggregate aggregate, IPermissionState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IPermissionStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IPermissionAggregate, IPermissionState>(aggregate, state, aggregate.Changes));
     }
 }