public bool addcommentmessage(int commentid) { using (var db = new oucfreetalkEntities()) { var searchcomment = db.postc.FirstOrDefault(a => a.id == commentid); if (searchcomment == null) { return(false); } var thispost = db.posts.FirstOrDefault(a => a.id == searchcomment.ownpost); try { notices ntc = new notices(); ntc.noticeclass = 1;//帖子被人回复 ntc.state = true; ntc.stuid = thispost.owner; ntc.replystuid = searchcomment.owner; ntc.createtime = searchcomment.createtime; ntc.postid = thispost.id; ntc.commentsid = searchcomment.id; db.notices.Add(ntc); if (db.SaveChanges() == 0) { return(false); } else { return(true); } }catch { return(false); } } }
public bool GetPostAccess(string userid, int postid) { using (var db = new oucfreetalkEntities()) { //权限 var searchaccess = (from it in db.accountaccess where it.studentid == userid && it.classid == -1 select it).ToList(); if (searchaccess.Count != 0) { return(true); //权限狗 } //post部分 var searchpost = (from it in db.posts where it.id == postid select it).ToList(); if (searchpost.Count == 0) { return(false); } if (searchpost[0].owner == userid) { return(true); //本人帖子 } var getac = db.accountaccess.FirstOrDefault(a => a.classid == searchpost[0].ownclass && a.studentid == userid); if (getac == null) { return(false); } else { return(true);//版主 } } }
public static void addbridata(string stuid, int actionid, int resultid) { using (var db = new oucfreetalkEntities()) { var bdata = new burieddata(); bdata.stuid = stuid; bdata.actionid = actionid; bdata.resultid = resultid; bdata.createtime = DateTime.Now; db.burieddata.Add(bdata); db.SaveChanges(); } }
public bool addreplymessage(int replyid) { using (var db = new oucfreetalkEntities()) { var searchreply = db.postreply.FirstOrDefault(a => a.id == replyid); if (searchreply == null) { return(false); } var thiscomment = db.postc.FirstOrDefault(a => a.id == searchreply.ownlocation); try { notices ntc = new notices(); ntc.noticeclass = 2;//楼层被人回复 ntc.state = true; ntc.stuid = thiscomment.owner; ntc.replystuid = searchreply.owner; ntc.createtime = searchreply.createtime; ntc.commentsid = thiscomment.id; ntc.postid = thiscomment.ownpost; ntc.replyid = searchreply.id; db.notices.Add(ntc); if (searchreply.replyto != thiscomment.owner)//如果不是回复评论主 { notices ntc2 = new notices(); ntc.noticeclass = 3;//楼层的回复被人回复了 ntc.state = true; ntc.stuid = searchreply.replyto; ntc.replystuid = searchreply.owner; ntc.createtime = searchreply.createtime; ntc.commentsid = thiscomment.id; ntc.postid = thiscomment.ownpost; ntc.replyid = searchreply.id; } if (db.SaveChanges() == 0) { return(false); } else { return(true); } } catch { return(false); } } }
public bool GetReplyAccess(string userid, int replyid) { using (var db = new oucfreetalkEntities()) { //权限 var searchaccess = (from it in db.accountaccess where it.studentid == userid && it.classid == -1 select it).ToList(); if (searchaccess.Count != 0) { return(true); //权限狗 } //reply部分 var searchpost = (from it in db.postreply join it2 in db.postc on it.ownlocation equals it2.id join it3 in db.posts on it2.ownpost equals it3.id where it.id == replyid select new { it.owner, commentowner = it2.owner, it3.ownclass }).ToList(); if (searchpost.Count == 0) { return(false); } if (searchpost[0].owner == userid) { return(true); //本人楼层 } if (searchpost[0].commentowner == userid) { return(true); //本人回复 } var getac = db.accountaccess.FirstOrDefault(a => a.classid == searchpost[0].ownclass && a.studentid == userid); if (getac == null) { return(false); } else { return(true);//版主 } } }