private ArticleModel GetArticle(Guid articleId) { using (var context = new NewsContext()) { var results = context .Articles .Where(x => x.Id == articleId) .Select(x => ArticleQueryHandlersHelper.SetModel(x)) .FirstOrDefault(); return(results); } }
private List <ArticleModel> GetArticlesByTag(Guid tagId) { using (var context = new NewsContext()) { var results = context .Articles .Include(x => x.ArticleTags) .Where(x => x.ArticleTags.Any(y => y.TagId == tagId)) .Select(x => ArticleQueryHandlersHelper.SetModel(x)) .ToList(); return(results); } }