public IResponseMessage GetByPublishDate(string content) { var wxArticles = new List <ResponseMessageNews.Article>(); using (var db = new WeChatDbContext()) { var items = from item in db.Articles where item.Published == content orderby item.Published descending select item; if (items.Count() == 0) { return(new ResponseMessageText("无此日期的文章,请尝试其他")); } foreach (var item in items) { var wxArticle = new ResponseMessageNews.Article { Description = item.Description, Title = item.Title, PicUrl = new Uri(item.PicUrl), Url = new Uri(item.Url) }; wxArticles.Add(wxArticle); } } return(new ResponseMessageNews(wxArticles.ToArray())); }
internal IResponseMessage GetByTag(string content) { var wxArticles = new List <ResponseMessageNews.Article>(); using (var db = new WeChatDbContext()) { var items = from item in db.Articles where item.Tags.Contains(content) orderby item.Published descending select item; if (items.Count() == 0) { return(null); } foreach (var item in items.Take(10)) { var wxArticle = new ResponseMessageNews.Article { Description = item.Description, Title = item.Title, PicUrl = new Uri(item.PicUrl), Url = new Uri(item.Url) }; wxArticles.Add(wxArticle); } } return(new ResponseMessageNews(wxArticles.ToArray())); }
public IResponseMessage GetTop() { var wxArticles = new List <ResponseMessageNews.Article>(); using (var db = new WeChatDbContext()) { var items = from item in db.Articles orderby item.Published descending select item; foreach (var item in items.Take(5)) { var wxArticle = new ResponseMessageNews.Article { Description = item.Description, Title = item.Title, PicUrl = new Uri(item.PicUrl), Url = new Uri(item.Url) }; wxArticles.Add(wxArticle); } } return(new ResponseMessageNews(wxArticles.ToArray())); }