public async Task <BlogInfoDto> GetBlogInfo() { var dto = new BlogInfoDto { ArticleTotal = await _articleRepo.Select.Where(a => !a.IsDeleted).CountAsync(), CategoryTotal = await _categoryRepo.Select.Where(c => !c.IsDeleted).CountAsync(), TagTotal = await _tagRepo.Select.Where(t => !t.IsDeleted).CountAsync(), CommentTotal = await _commentRepo.Select.Where(c => !c.IsDeleted).CountAsync() }; return(dto); }
public async Task <BlogInfoDto> GetBlogInfoAsync(string id) { if (string.IsNullOrEmpty(id)) { throw new BusinessException(1001, "id不能为空"); } var blogInfo = await _context.BlogInfos.FindAsync(new Guid(id)); var blogDto = new BlogInfoDto(); if (blogInfo != null) { blogDto = _mapper.Map <BlogInfoDto>(blogInfo); } return(blogDto); }