/// <summary> /// 发表讨论话题 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddDiscuss(DiscussInfo model) { string sqltxt = @"INSERT INTO qds157425440_db.dbo.DiscussInfo ( Title , Dcontent , ClickCount , Dstatus , CommentCount , IsTop , AddTime , UpdateTime , PUserID , PuserName ) VALUES ( @Title , @Dcontent , 0 , 10 , 0 , 0 , GETDATE() , GETDATE() , @PUserID , @PuserName )"; SqlParameter[] paramter = { new SqlParameter("@Title",model.Title), new SqlParameter("@Dcontent",model.Dcontent), new SqlParameter("@PUserID",model.PUserID), new SqlParameter("@PuserName",model.PUserName) }; int rowcount = helper.ExecuteSql(sqltxt, paramter); return rowcount; }
public ActionResult PublishDiscuss(string title, string content) { if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(content)) { return Json("请完善标题或内容"); } MemberInfo member = (MemberInfo)Session["member"]; if (member == null) { return Json("-2"); } DiscussInfo model = new DiscussInfo(); model.Title = title; model.Dcontent = content; model.PUserID = member.MID; model.PUserName = member.Name; int rowcount = dbll.AddDiscuss(model); if (rowcount > 0) return Json("1"); else return Json("0"); }
/// <summary> /// 得到独立的讨论信息 /// </summary> /// <returns></returns> public DiscussInfo GetDiscuessByID(int ID) { DiscussInfo info = new DiscussInfo(); string sqltxt = @"SELECT Did , Title , Dcontent , ClickCount , Dstatus , CommentCount , IsTop , AddTime , UpdateTime,PUserID,PuserName FROM qds157425440_db.dbo.DiscussInfo WITH ( NOLOCK ) WHERE did = @id AND Dstatus = 10"; using (SqlConnection conn = new SqlConnection(sqlconnectstr)) { info = conn.Query<DiscussInfo>(sqltxt, new { id = ID }).ToList<DiscussInfo>().FirstOrDefault(); } return info; }
/// <summary> /// 发表讨论话题 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddDiscuss(DiscussInfo model) { return dal.AddDiscuss(model); }