public Activity GetActByID(Guid actid) { using (var db = new FirewoodContext()) { return(db.Activities.Find(actid)); } }
public List <Guid> GetTopActList() { using (var db = new FirewoodContext()) { var result = db.Joins.GroupBy(x => x.ActID).OrderByDescending(x => x.Count()).Select(x => x.Key).ToList <Guid>(); return(result); } }
public bool AddComment(Comment comment) { using (var db = new FirewoodContext()) { db.Comments.Add(comment); return(db.SaveChanges() == 1 ? true : false); } }
public Org GetOrgByID(Guid orgid) { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.State > 0 && x.OrgID.Equals(orgid)).FirstOrDefault(); return(org); } }
public List <Org> GetAllOrg(int n, int page) { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.State > 0).OrderByDescending(x => x.RegisterTime); return(org.Skip(n * (page - 1)).Take(n).ToList <Org>()); } }
public List <Activity> GetActByClass2(string class2, int n, int page) { using (var db = new FirewoodContext()) { var activities = db.Activities.Where(x => x.Class2 == class2 && x.State > 0).OrderByDescending(x => x.BeginTime); return(activities.Skip(n * (page - 1)).Take(n).ToList <Activity>()); } }
public Org GetOrgByName(string orgname) { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.OrgName == orgname).FirstOrDefault(); return(org); } }
public bool OrgNameRegistered(string orgname) { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.OrgName == orgname && x.State > 0).FirstOrDefault(); return(org != null); } }
public List <Activity> GetActByOrgID(Guid orgid, int n, int page) { using (var db = new FirewoodContext()) { var activities = db.Activities.Where(x => x.OrgID == orgid && x.State > 0).OrderByDescending(x => x.BeginTime); return(activities.Skip(n * (page - 1)).Take(n).ToList <Activity>()); } }
public int GetSumByActID(Guid actid) { using (var db = new FirewoodContext()) { var joinList = db.Joins.Where(x => x.ActID == actid && x.Status == 1); return(joinList.Count()); } }
public int GetActCount(Guid orgid) { using (var db = new FirewoodContext()) { var org = db.Activities.Where(x => x.OrgID.Equals(orgid)); return(org.Count()); } }
public List <Activity> GetActByTitle(string title, int n, int page) { using (var db = new FirewoodContext()) { var activities = db.Activities.Where(x => x.ActName.Contains(title) && x.EndTime > DateTime.Now && x.State > 0).OrderByDescending(x => x.BeginTime); return(activities.Skip(n * (page - 1)).Take(n).ToList <Activity>()); } }
public int GetOrgCount() { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.State > 0); return(org.Count()); } }
public bool Delete(Guid actid) { using (var db = new FirewoodContext()) { var act = db.Activities.Find(actid); act.State = -1; return(db.SaveChanges() == 1); } }
public bool Create(Activity act) { act.State = 1; using (var db = new FirewoodContext()) { db.Activities.Add(act); return(db.SaveChanges() == 1); } }
public bool UpdateLoginTime(string orgname) { using (var db = new FirewoodContext()) { var org = db.Orgs.Where(x => x.OrgName == orgname).FirstOrDefault(); org.LastLogin = DateTime.Now; return(db.SaveChanges() == 1); } }
public bool Delete(Guid orgid) { using (var db = new FirewoodContext()) { var org = db.Orgs.Find(orgid); org.State = -1; return(db.SaveChanges() == 1); } }
//根据用户id查看留言 public List <Comment> selectByUserID(Guid userID, int n, int page) { using (var db = new FirewoodContext()) { var a = db.Comments.Where(x => x.UserID == userID && x.Type == 1 && x.State > 0); var b = a.OrderByDescending(x => x.ComTime).Skip(n * (page - 1)).Take(n).ToList <Comment>(); return(b); } }
public bool Delete(Guid actid, Guid userid) { using (var db = new FirewoodContext()) { var join = db.Joins.Where(x => x.ActID == actid && x.UserID == userid && x.Status == 1).FirstOrDefault(); join.Status = -1; return(db.SaveChanges() == 1 ? true : false); } }
public bool Create(Join join) { join.Status = 1; using (var db = new FirewoodContext()) { db.Joins.Add(join); return(db.SaveChanges() == 1 ? true : false); } }
public List <Guid> GetActListByUserID(Guid userid) { using (var db = new FirewoodContext()) { var join = (from o in db.Joins where o.UserID.Equals(userid) && o.Status > 0 select o.ActID); return(join.ToList <Guid>()); } }
public bool Create(Org org) { org.RegisterTime = DateTime.Now; org.LastLogin = DateTime.Now; org.State = 1; using (var db = new FirewoodContext()) { db.Orgs.Add(org); return(db.SaveChanges() == 1); } }
public bool Update(Org org) { using (var db = new FirewoodContext()) { var x = db.Orgs.Find(org.OrgID); x.OrgDepartment = org.OrgDepartment; x.OrgIntroduction = org.OrgIntroduction; x.OrgContact = org.OrgContact; return(db.SaveChanges() == 1); } }
public bool DeleteByActID(Guid actid) { using (var db = new FirewoodContext()) { var joins = db.Joins.Where(x => x.ActID == actid && x.Status == 1); foreach (Join join in joins) { join.Status = -1; } return(db.SaveChanges() > 0 ? true : false); } }
//查看某个活动的最新的几条留言 public List <Comment> selectCommentByActID_num(Guid ActID, int num) { using (var db = new FirewoodContext()) { var a = db.Comments.Where(x => x.ActID == ActID && x.Type == 1 && x.State > 0); var b = a.OrderByDescending(x => x.ComTime); if (b.ToList <Comment>().Count >= 5) { return(b.Take(num).ToList <Comment>()); } return(b.ToList <Comment>()); } }
//其实就是添加留言 #endregion #region 修改被回复留言的NextComID public bool AddNextComID(Guid ComID, Guid NextComID) { using (var db = new FirewoodContext()) { var a = db.Comments.Where(x => x.ComID == ComID).FirstOrDefault(); if (a == null) { return(false); } a.NextComID = NextComID; return(db.SaveChanges() == 1 ? true : false); } }
//查看回复情况 public List <Comment> selectCommentByComID(Guid ComID) { using (var db = new FirewoodContext()) { var a = db.Comments.Where(x => x.ComID == ComID).FirstOrDefault().NextComID; List <Comment> commentList = new List <Comment>(); while (a != null) { var b = db.Comments.Where(x => x.ComID == a && x.State > 0).FirstOrDefault(); commentList.Add(b); a = b.NextComID; } return(commentList); } }
public bool DeleteByOrgID(Guid orgid) { using (var db = new FirewoodContext()) { var activities = db.Activities.Where(x => x.OrgID == orgid && x.State > 0); foreach (Activity act in activities) { var results = db.Joins.Where(x => x.ActID == act.ActID && x.Status > 0); foreach (Join join in results) { join.Status = -1; } act.State = -1; } return(db.SaveChanges() >= 0); } }
public bool IsExist(Guid actid, Guid uid) { using (var db = new FirewoodContext()) { var join = db.Joins.Where(x => x.ActID == actid && x.UserID == uid).FirstOrDefault(); if (join == null) { return(false); } else if (join.Status == -1) { return(false); } else if (join.Status == 1) { return(true); } return(true); } }