Beispiel #1
0
        public async Task <ArticleDto> GetOneArticleById(Guid articleId)
        {
            using (var articleSvc = new DAL.ArticleService())
            {
                var data = await articleSvc.GetAllAsync().Include(m => m.User).Where(m => m.Id == articleId).Select(m => new Dto.ArticleDto()
                {
                    Id         = m.Id,
                    Title      = m.Title,
                    Content    = m.Content,
                    CreateTime = m.CreateTime,
                    GoodCount  = m.GoodCount,
                    BadCount   = m.BadCount,
                    Email      = m.User.Email,
                    ImagePath  = m.User.ImagePath
                }).FirstAsync();

                using (var articleToCategroySvc = new DAL.ArticleToCategoryService())
                {
                    var articleToCategroyData = articleToCategroySvc.GetAllAsync().Include(m => m.BlogCategory).Where(m => m.ArticleId == data.Id);
                    data.CategoryIds   = articleToCategroyData.Select(m => m.BlogCategoryId).ToArray();
                    data.CategoryNames = articleToCategroyData.Select(m => m.BlogCategory.CategoryName).ToArray();

                    return(data);
                }
            }
        }
Beispiel #2
0
 public async Task <bool> ExistsArticle(Guid articleId)
 {
     using (var articleSvc = new DAL.ArticleService())
     {
         return(await articleSvc.GetAllAsync().AnyAsync(m => m.Id == articleId));
     }
 }
Beispiel #3
0
 public async Task <int> GetDataCount(Guid userId)
 {
     using (var articleSvc = new DAL.ArticleService())
     {
         return(await articleSvc.GetAllAsync().CountAsync(m => m.UserId == userId));
     }
 }