예제 #1
0
        public List <DynamicEntityProperty> GetAll(string entityFullName)
        {
            var allProperties = DynamicEntityPropertyStore.GetAll(entityFullName);

            allProperties = allProperties.Where(dynamicEntityProperty =>
                                                _dynamicPropertyPermissionChecker.IsGranted(dynamicEntityProperty.DynamicPropertyId))
                            .ToList();
            return(allProperties);
        }
예제 #2
0
        public virtual DynamicEntityProperty Get(int id)
        {
            var tenantId = GetCurrentTenantId();
            var cacheKey = GetCacheKey(id, tenantId);

            var entityProperty = DynamicEntityPropertyCache.Get(cacheKey, () => DynamicEntityPropertyStore.Get(id));

            _dynamicPropertyPermissionChecker.CheckPermission(entityProperty.DynamicPropertyId);
            return(entityProperty);
        }
예제 #3
0
        public virtual async Task <DynamicEntityProperty> GetAsync(int id)
        {
            var tenantId = GetCurrentTenantId();
            var cacheKey = GetCacheKey(id, tenantId);

            var entityProperty =
                await DynamicEntityPropertyCache.GetAsync(cacheKey, () => DynamicEntityPropertyStore.GetAsync(id));

            await _dynamicPropertyPermissionChecker.CheckPermissionAsync(entityProperty.DynamicPropertyId);

            return(entityProperty);
        }
예제 #4
0
        public virtual async Task UpdateAsync(DynamicEntityProperty dynamicEntityProperty)
        {
            CheckEntityName(dynamicEntityProperty.EntityFullName);
            await _dynamicPropertyPermissionChecker.CheckPermissionAsync(dynamicEntityProperty.DynamicPropertyId);

            using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
            {
                await DynamicEntityPropertyStore.UpdateAsync(dynamicEntityProperty);

                await uow.CompleteAsync();
            }

            var cacheKey = GetCacheKey(dynamicEntityProperty.Id, dynamicEntityProperty.TenantId);
            await DynamicEntityPropertyCache.SetAsync(cacheKey, dynamicEntityProperty);
        }
예제 #5
0
        public virtual void Update(DynamicEntityProperty dynamicEntityProperty)
        {
            CheckEntityName(dynamicEntityProperty.EntityFullName);
            _dynamicPropertyPermissionChecker.CheckPermission(dynamicEntityProperty.DynamicPropertyId);

            using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
            {
                DynamicEntityPropertyStore.Update(dynamicEntityProperty);
                uow.Complete();
            }

            var cacheKey = GetCacheKey(dynamicEntityProperty.Id, dynamicEntityProperty.TenantId);

            DynamicEntityPropertyCache.Set(cacheKey, dynamicEntityProperty);
        }
예제 #6
0
        public async Task <List <DynamicEntityProperty> > GetAllAsync(string entityFullName)
        {
            var allProperties = await DynamicEntityPropertyStore.GetAllAsync(entityFullName);

            var controlledProperties = new List <DynamicEntityProperty>();

            foreach (var dynamicEntityProperty in allProperties)
            {
                if (await _dynamicPropertyPermissionChecker.IsGrantedAsync(dynamicEntityProperty.DynamicPropertyId))
                {
                    controlledProperties.Add(dynamicEntityProperty);
                }
            }

            return(controlledProperties);
        }
예제 #7
0
        public virtual async Task DeleteAsync(int id)
        {
            var dynamicEntityProperty = await GetAsync(id); //Get checks permission, no need to check it again

            if (dynamicEntityProperty == null)
            {
                return;
            }

            await DynamicEntityPropertyStore.DeleteAsync(dynamicEntityProperty.Id);

            var tenantId = GetCurrentTenantId();
            var cacheKey = GetCacheKey(id, tenantId);

            await DynamicEntityPropertyCache.RemoveAsync(cacheKey);
        }
예제 #8
0
        public virtual void Delete(int id)
        {
            var dynamicEntityProperty = Get(id); //Get checks permission, no need to check it again

            if (dynamicEntityProperty == null)
            {
                return;
            }

            DynamicEntityPropertyStore.Delete(dynamicEntityProperty.Id);

            var tenantId = GetCurrentTenantId();
            var cacheKey = GetCacheKey(id, tenantId);

            DynamicEntityPropertyCache.Remove(cacheKey);
        }