Esempio n. 1
0
 public NewsDetailDTO GetNewsDetail(int userId, int id)
 {
     using (EFDbFactory db = new EFDbFactory())
     {
         var query = from n in db.news
                     join u in db.user on n.user_id equals u.id
                     join c in db.category on n.category_id equals c.id into temp
                     from tt in temp.DefaultIfEmpty()
                     where n.id == id && n.user_id == userId
                     select new NewsDetailDTO
         {
             id             = n.id,
             title          = n.title,
             description    = n.description,
             userName       = u.name,
             categoryName   = tt.name,
             number         = n.number,
             goodNumber     = n.good_number,
             createDateTime = n.create_date_time,
             Content        = n.content
         };
         NewsDetailDTO newsDTO = query.FirstOrDefault();
         if (newsDTO != null)
         {
             var newsQuery = from nt in db.news_tag
                             join t in db.tag on nt.tag_id equals t.id
                             where nt.news_id == newsDTO.id
                             select t;
             newsDTO.tag = newsQuery.ToList();
         }
         return(newsDTO);
     }
 }
Esempio n. 2
0
        public IActionResult Details(int id)
        {
            NewsDetailDTO entity = newsRepository.GetNewsDetail(userId, id);

            //查询文章标签
            ViewBag.NewsTagList = newsRepository.GetNewsTagList(id);

            ViewBag.PerNextNewsList          = newsRepository.GetPerNextNews(userId, id);
            ViewBag.RelevantArticlesNewsList = newsRepository.GetRelevantArticlesList(userId, id, 10);

            //更新点击率
            newsRepository.UpdateClickNumber(id);

            return(View(userBlogTemplate + "News/Details.cshtml", entity));
        }
 public NewsReceivedArgs(NewsDetailDTO newsDetailDTO)
 {
     NewsDetail = newsDetailDTO;
 }