public async Task CancelCollect(Guid userId, Guid articleId) { using (IArticleCollectService articleCollect = new ArticleCollectService()) { var data = await articleCollect.GetAllAsync() .FirstOrDefaultAsync(m => m.UserId == userId && m.ArticleId == articleId); await articleCollect.RemoveAsync(data, save : true); } }
public async Task <List <ArticleCollectDto> > GetAllArticleByCollect() //文章收藏排序 { using (IArticleCollectService articleCollect = new ArticleCollectService()) { return(await articleCollect.GetAllAsync() .Include(m => m.Article) .Select(m => new ArticleCollectDto() { Title = m.Article.Title, ArticleId = m.ArticleId }).ToListAsync()); } }
public async Task <List <ArticleCollectDto> > GetAllArticleCollectByUser(Guid userid) //查询我的收藏 { using (IArticleCollectService artCollectService = new ArticleCollectService()) { var data = await artCollectService.GetAllAsync() .Where(m => m.UserId == userid) .Include(m => m.Article) .Select(m => new ArticleCollectDto() { Title = m.Article.Title, ArticleId = m.ArticleId }).ToListAsync(); return(data); } }
public async Task <ArticleCollectDto> GetArticleIsCollect(Guid userId, Guid articleId) { using (IArticleCollectService artSvc = new ArticleCollectService()) { try { var data = await artSvc.GetAllAsync() .Where(m => m.UserId == userId) .Where(m => m.ArticleId == articleId) .Select(m => new ArticleCollectDto() { ArticleId = m.ArticleId }).FirstAsync(); return(data); } catch (Exception e) { return(null); } } }