public ActionResult DeleteBlog(ajaxClass.Articles accept)
 {
     Model.Articles rec = db.Articles.Where(o => o.id == accept.id).FirstOrDefault();
     db.Articles.Remove(rec);
     db.SaveChanges();
     return(Content("删除成功!"));
 }
Esempio n. 2
0
        public ActionResult Save()
        {
            Articles articles = new Articles();

            articles.title       = Request["title"];
            articles.content     = Request.Unvalidated().Form["content"].ToString();
            articles.users_id    = Convert.ToInt32(Session["User_id"]);
            articles.like_num    = 12;
            articles.comment_num = 12;
            articles.views_num   = 100;
            articles.creat_time  = DateTime.Now;
            linxinDb.Articles.Add(articles);
            linxinDb.SaveChanges();
            return(Content("<script>;alert('发布成功!返回首页!');window.location.href='/Home/Index'</script>"));
        }
Esempio n. 3
0
        public ActionResult Comment()
        {
            Art_Comment art_Comment = new Art_Comment();

            art_Comment.article_id = Convert.ToInt32(Request["article_id"]);
            art_Comment.users_id   = Convert.ToInt32(Session["User_id"]);
            art_Comment.content    = Request["comment"];
            int id = art_Comment.article_id;

            linxinDb.Art_Comment.Add(art_Comment);
            linxinDb.SaveChanges();
            artClass.articles     = linxinDb.Articles.Where(n => n.id == id).Select(n => n);
            artClass.art_Comments = from n in linxinDb.Art_Comment
                                    where n.article_id == id
                                    where n.parent_comment_id == null
                                    select n;

            ViewBag.likenum = linxinDb.likes_art.Where(n => n.art_id == id).Count();
            return(View("detail", artClass));
        }
Esempio n. 4
0
        //评论
        public ActionResult sciComment()
        {
            Sci_Comment sci_Comment = new Sci_Comment();

            sci_Comment.article_id = Convert.ToInt32(Request["article_id"]);
            sci_Comment.users_id   = Convert.ToInt32(Session["User_id"]);
            sci_Comment.content    = Request["comment"];
            int id = sci_Comment.article_id;

            linxinDb.Sci_Comment.Add(sci_Comment);
            linxinDb.SaveChanges();
            SciClass.sci_Articles = linxinDb.Sci_articles.Where(n => n.id == id).Select(n => n);
            SciClass.sci_Comments = from n in linxinDb.Sci_Comment
                                    where n.article_id == id
                                    where n.parent_comment_id == null
                                    select n;

            ViewBag.likenum = linxinDb.likes_sci.Where(n => n.sci_id == id).Count();
            return(View("sci_article", SciClass));
        }
Esempio n. 5
0
        public ActionResult Newscomment()
        {
            News_Comment news_Comment = new News_Comment();

            news_Comment.article_id = Convert.ToInt32(Request["article_id"]);
            news_Comment.users_id   = Convert.ToInt32(Session["User_id"]);
            news_Comment.content    = Request["comment"];
            int id = news_Comment.article_id;

            linxinDb.News_Comment.Add(news_Comment);
            linxinDb.SaveChanges();
            newsClass.psy_News      = linxinDb.Psy_news.Where(n => n.id == id).Select(n => n);
            newsClass.news_Comments = from n in linxinDb.News_Comment
                                      where n.article_id == id
                                      where n.parent_comment_id == null
                                      select n;

            ViewBag.likenum = linxinDb.likes_news.Where(n => n.news_id == id).Count();
            return(View("News_article", newsClass));
        }
Esempio n. 6
0
 public void RemoveUser(Users user)
 {
     db.Users.Remove(user);
     db.SaveChanges();
 }
Esempio n. 7
0
 public void RemoveArticle(Articles article)
 {
     db.Articles.Remove(article);
     db.SaveChanges();
 }