예제 #1
0
        public async Task DeleteCategory(string id)
        {
            if (!await _categoryRepository.Exist(id))
            {
                throw new BusinessException("分类不存在!");
            }

            if (await _categoryRepository.HasChild(id))
            {
                throw new BusinessException("含有子分类,无法删除!");
            }

            if (await _articleRepository.ExistsByCategoryId(id))
            {
                throw new BusinessException("该分类下已存在文章,无法删除!");
            }

            await _categoryRepository.DeleteById(id);
        }