예제 #1
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> entities)
        {
            DataPrivilegeContext <TDbContext, TEntity, TRule> context = CreateDataPrivilegeContext(DataOperation.Read);

            if (context != null)
            {
                return(context.Filter(entities));
            }
            return(entities);
        }
예제 #2
0
        public IQueryable <TEntity> GetAll()
        {
            IQueryable <TEntity> table = DbContext.Set <TEntity>();
            DataPrivilegeContext <TDbContext, TEntity, TRule> context = CreateDataPrivilegeContext(DataOperation.Read);

            if (context != null)
            {
                table = context.Filter(table);
            }
            return(table);
        }
예제 #3
0
        public void CheckPermission(TEntity entity, DataOperation dataOperation)
        {
            DataPrivilegeContext <TDbContext, TEntity, TRule> context = CreateDataPrivilegeContext(dataOperation);

            if (context != null)
            {
                if (!context.CheckPermission(entity))
                {
                    throw new NoAccessException(entity, dataOperation);
                }
            }
        }
예제 #4
0
        public void CheckPermission(IEnumerable <TEntity> entities, DataOperation dataOperation)
        {
            DataPrivilegeContext <TDbContext, TEntity, TRule> context = CreateDataPrivilegeContext(dataOperation);

            if (context != null)
            {
                if (!context.CheckPermission(entities))
                {
                    var data = context.GetNoAccessData(entities);
                    throw new NoAccessException(data, dataOperation);
                }
            }
        }