/// <summary>
        /// 刪除分類
        /// </summary>
        /// <param name="category_id"></param>
        /// <returns></returns>
        public async Task <string> DeleteCategory(Guid category_id)
        {
            var checkArticle = await _articleRepo.GetArticleList(category_id);

            if (checkArticle.Count() > 0)
            {
                return("此分類下有文章,不能刪除");
            }
            await _categoryRepo.DeleteCategory(category_id);

            return("success");
        }
Example #2
0
        /// <summary>
        /// 文章列表
        /// </summary>
        /// <param name="category_id"></param>
        /// <returns></returns>
        public async Task <dynamic> ArticleList(Guid category_id)
        {
            var GetArticle = await _articleRepo.GetArticleList(category_id);

            if (GetArticle.Count() < 1)
            {
                return("查無資料");
            }
            var result = GetArticle.Select(x => new ArticleListViewModel.data()
            {
                article_id    = x.article_id,
                category_name = x.category_name,
                name          = x.article_name,
                content       = x.article_content,
            }).ToList();

            return(result);
        }