Example #1
0
        public bool DeleteById(bool deleteTable = true, params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result = false;

            using (UnitOfWork.Build(_entityRepository.DbContext))
            {
                foreach (var item in id)
                {
                    var deleted = _entityRepository.FindById(item);
                    if (deleted == null || !deleted.IsCustomizable)
                    {
                        continue;
                    }
                    //检查依赖项
                    _dependencyChecker.CheckAndThrow <Domain.Entity>(EntityDefaults.ModuleName, item);
                    //cascade delete
                    _cascadeDeletes?.ToList().ForEach((x) => { x.CascadeDelete(deleted); });
                    result = _entityRepository.DeleteById(item, deleteTable);
                    //删除依赖项
                    _dependencyService.DeleteByDependentId(EntityDefaults.ModuleName, item);
                    //solution component
                    _solutionComponentService.DeleteObject(deleted.SolutionId, deleted.EntityId, EntityDefaults.ModuleName);
                    //entity localization
                    _localizedLabelService.DeleteByObject(deleted.EntityId);
                    //remove from cache
                    _cacheService.RemoveEntity(deleted);
                }
            }
            return(result);
        }
Example #2
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result = true;

            foreach (var item in id)
            {
                var deleted = _webResourceRepository.FindById(item);
                if (deleted == null)
                {
                    return(false);
                }
                //检查依赖项
                _dependencyChecker.CheckAndThrow <Domain.WebResource>(WebResourceDefaults.ModuleName, deleted.WebResourceId);
                bool flag = _webResourceRepository.DeleteById(item);
                if (flag)
                {
                    //删除依赖项
                    _dependencyService.DeleteByDependentId(WebResourceDefaults.ModuleName, id);
                    //solution component
                    _solutionComponentService.DeleteObject(deleted.SolutionId, deleted.WebResourceId, WebResourceDefaults.ModuleName);
                    //localization
                    _localizedLabelService.DeleteByObject(item);
                    _cacheService.RemoveEntity(deleted);
                }
            }
            return(result);
        }
Example #3
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result   = true;
            var deleteds = _ribbonButtonRepository.Query(x => x.RibbonButtonId.In(id));

            if (deleteds.NotEmpty())
            {
                result = DeleteCore(deleteds, (deleted) =>
                {
                    _dependencyChecker.CheckAndThrow <Domain.RibbonButton>(RibbonButtonDefaults.ModuleName, deleted.RibbonButtonId);
                    return(true);
                });
            }
            return(result);
        }
Example #4
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result   = false;
            var deleteds = _chartRepository.Query(x => x.ChartId.In(id));

            if (deleteds.NotEmpty())
            {
                result = DeleteCore(deleteds, (deleted) =>
                {
                    //检查依赖项
                    _dependencyChecker.CheckAndThrow <Chart>(ChartDefaults.ModuleName, deleted.ChartId);
                    return(true);
                });
            }
            return(result);
        }
Example #5
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result   = false;
            var deleteds = _systemFormRepository.Query(x => x.SystemFormId.In(id));

            if (deleteds.NotEmpty())
            {
                result = DeleteCore(deleteds, (deleted) =>
                {
                    if (deleted.IsDefault)
                    {
                        return(false);
                    }
                    //检查依赖项
                    _dependencyChecker.CheckAndThrow <Schema.Domain.Entity>(FormDefaults.ModuleName, deleted.SystemFormId);
                    return(true);
                });
            }
            return(result);
        }
Example #6
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result   = true;
            var deleteds = _queryViewRepository.Query(x => x.QueryViewId.In(id));

            if (deleteds.NotEmpty())
            {
                result = DeleteCore(deleteds, (deleted) =>
                {
                    if (deleted.IsDefault)
                    {
                        return(false);
                    }
                    //检查依赖项
                    _dependencyChecker.CheckAndThrow <Domain.QueryView>(QueryViewDefaults.ModuleName, deleted.QueryViewId);
                    return(true);
                });
            }
            return(result);
        }
Example #7
0
        public bool DeleteById(params Guid[] id)
        {
            Guard.NotEmpty(id, nameof(id));
            var result   = false;
            var deleteds = _attributeRepository.Query(x => x.AttributeId.In(id));

            if (deleteds.NotEmpty())
            {
                result = DeleteCore(deleteds, (deleted) =>
                {
                    //检查是否允许删除
                    if (deleted == null || !deleted.IsCustomField)
                    {
                        throw new XmsException(_loc["attribute_notallow_delete"]);
                    }
                    //检查是否存在引用
                    _dependencyChecker.CheckAndThrow <Domain.Attribute>(AttributeDefaults.ModuleName, deleted.AttributeId);
                    return(true);
                });
            }
            return(result);
        }