/// <summary>
 /// 查找评论数
 /// </summary>
 /// <param name="comFilter">对象</param>
 /// <returns>int</returns>
 public static dynamic FindCommentSum(CMS_Comment comFilter)
 {
     using (CMSDatabase_Model cms = new CMSDatabase_Model())
     {
         try
         {
             var list = from data in cms.CMS_Comment
                        select data;
             if (comFilter.aid == 0)
             {
                 throw new System.Exception("需要知道是哪一篇文章的评论");
             }
             else
             {
                 list = list.Where(data => data.aid == comFilter.aid).Select(data => data);
             }
             var count = list.Count();
             return(count);
         }
         catch (Exception error)
         {
             throw error;
         }
     }
 }
        public ActionResult addComment(CMS_Comment com)
        {
            int uid = 0;

            if (Session["name"] != null)
            {
                CMS_User c = db.Userid(Session["name"].ToString());
                uid = c.uid;
            }
            com.cmtime = DateTime.Now;
            com.uid    = uid;
            V_CMS_Comment v = new V_CMS_Comment()
            {
                nname  = Session["name"].ToString(),
                cmtime = com.cmtime,
            };

            if (db.addCMS_Comment(com) > 0)
            {
                return(Json(v));
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
 /// <summary>
 /// 添加评论
 /// </summary>
 /// <param name="com">对象</param>
 /// <returns>int</returns>
 public static dynamic Add(CMS_Comment com)
 {
     try
     {
         return(CMS_Comment_DAL.Add(com));
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Exemple #4
0
 /// <summary>
 /// 查找评论数
 /// </summary>
 /// <param name="comFilter">对象</param>
 /// <returns>int</returns>
 public static dynamic FindCommentSum(CMS_Comment comFilter)
 {
     try
     {
         var count = CMS_Comment_DAL.FindCommentSum(comFilter);
         return(count);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
        //文章内容
        public ActionResult LaceMian(int id = 0)
        {
            try
            {
                if (id == 0)
                {
                    Response.Redirect("/Front/Home/Index");
                }
                else
                {
                    //查找文章
                    ArticleMain_View artFilter = new ArticleMain_View();
                    artFilter.aid = id;
                    var listArticle = CMS_Article_BLL.Find(artFilter);
                    ViewBag.articleList = listArticle;
                    //查账该文章的评论数
                    CMS_Comment comFilter = new CMS_Comment();
                    comFilter.aid = id;
                    var countCommentSum = CMS_Comment_BLL.FindCommentSum(comFilter);
                    if (countCommentSum == 0)
                    {
                        ViewBag.commentSumCount = 0;
                    }
                    else
                    {
                        ViewBag.commentSumCount = countCommentSum;
                    }
                    //查找该文章的评论
                    CommentMain_View comView = new CommentMain_View();
                    comView.aid = id;
                    var listComment = CMS_Comment_BLL.Find(comView);
                    ViewBag.commentList = listComment;

                    if (Session["userID"] != null)
                    {
                        ViewBag.userID = Session["userID"].ToString();
                    }
                    else
                    {
                        ViewBag.userID = "0";
                    }
                }
            }
            catch (Exception error)
            {
                throw error;
            }

            return(View());
        }
 /// <summary>
 /// 添加评论
 /// </summary>
 /// <param name="com">对象</param>
 /// <returns>int</returns>
 public static dynamic Add(CMS_Comment com)
 {
     try
     {
         using (CMSDatabase_Model cms = new CMSDatabase_Model())
         {
             cms.CMS_Comment.Add(com);
             var count = cms.SaveChanges();
             return(count);
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 public ActionResult AddComment(string cmhtml, int uid, int aid)
 {
     try
     {
         if (string.IsNullOrEmpty(cmhtml) || aid == 0 || uid == 0)
         {
             throw new System.Exception("评论内容没有等其他原因");
         }
         CMS_Comment com = new CMS_Comment();
         com.aid    = aid;
         com.uid    = uid;
         com.cmtime = DateTime.Now;
         com.cmhtml = cmhtml;
         var count = CMS_Comment_BLL.Add(com);
         return(Json(count));
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 public ActionResult AddComment(int aid, string cmhtml)
 {
     if (Session["user"] == null)
     {
         return(Json(new
         {
             state = false,
             message = "请先登录"
         }));
     }
     else
     {
         CMS_Comment c = new CMS_Comment()
         {
             aid    = aid,
             uid    = (Session["user"] as CMS_User).uid,
             cmtime = DateTime.Now,
             cmhtml = cmhtml
         };
         if (db.AddCommentCount(aid) > 0)
         {
         }
         if (db.AddComment(c) > 0)
         {
             return(Json(new
             {
                 state = true,
                 message = "评论成功"
             }));
         }
         else
         {
             return(Json(new
             {
                 state = false,
                 message = "网络貌似出问题了..."
             }));
         }
     }
 }
Exemple #9
0
 /// <summary>
 /// 添加评论
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public int AddComment(CMS_Comment c)
 {
     db.CMS_Comment.Add(c);
     return(db.SaveChanges());
 }
Exemple #10
0
 //layout1 评论内容修改
 public int editcom(CMS_Comment u)
 {
     db.Entry <CMS_Comment>(u).State = System.Data.Entity.EntityState.Modified;
     return(db.SaveChanges());
 }
Exemple #11
0
 public int addCMS_Comment(CMS_Comment com)
 {
     db.CMS_Comment.Add(com);
     return(db.SaveChanges());
 }
Exemple #12
0
 //layout1修改评论内容
 public int editcom(CMS_Comment u)
 {
     return(db.editcom(u));
 }