Beispiel #1
0
 public Activity GetActByID(Guid actid)
 {
     using (var db = new FirewoodContext())
     {
         return(db.Activities.Find(actid));
     }
 }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
 public bool AddComment(Comment comment)
 {
     using (var db = new FirewoodContext())
     {
         db.Comments.Add(comment);
         return(db.SaveChanges() == 1 ? true : false);
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 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>());
     }
 }
Beispiel #6
0
 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>());
     }
 }
Beispiel #7
0
 public Org GetOrgByName(string orgname)
 {
     using (var db = new FirewoodContext())
     {
         var org = db.Orgs.Where(x => x.OrgName == orgname).FirstOrDefault();
         return(org);
     }
 }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
 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>());
     }
 }
Beispiel #10
0
 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());
     }
 }
Beispiel #11
0
 public int GetActCount(Guid orgid)
 {
     using (var db = new FirewoodContext())
     {
         var org = db.Activities.Where(x => x.OrgID.Equals(orgid));
         return(org.Count());
     }
 }
Beispiel #12
0
 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>());
     }
 }
Beispiel #13
0
 public int GetOrgCount()
 {
     using (var db = new FirewoodContext())
     {
         var org = db.Orgs.Where(x => x.State > 0);
         return(org.Count());
     }
 }
Beispiel #14
0
 public bool Delete(Guid actid)
 {
     using (var db = new FirewoodContext())
     {
         var act = db.Activities.Find(actid);
         act.State = -1;
         return(db.SaveChanges() == 1);
     }
 }
Beispiel #15
0
 public bool Create(Activity act)
 {
     act.State = 1;
     using (var db = new FirewoodContext())
     {
         db.Activities.Add(act);
         return(db.SaveChanges() == 1);
     }
 }
Beispiel #16
0
 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);
     }
 }
Beispiel #17
0
 public bool Delete(Guid orgid)
 {
     using (var db = new FirewoodContext())
     {
         var org = db.Orgs.Find(orgid);
         org.State = -1;
         return(db.SaveChanges() == 1);
     }
 }
Beispiel #18
0
 //根据用户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);
     }
 }
Beispiel #19
0
 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);
     }
 }
Beispiel #20
0
 public bool Create(Join join)
 {
     join.Status = 1;
     using (var db = new FirewoodContext())
     {
         db.Joins.Add(join);
         return(db.SaveChanges() == 1 ? true : false);
     }
 }
Beispiel #21
0
 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>());
     }
 }
Beispiel #22
0
 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);
     }
 }
Beispiel #23
0
 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);
     }
 }
Beispiel #24
0
 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);
     }
 }
Beispiel #25
0
 //查看某个活动的最新的几条留言
 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>());
     }
 }
Beispiel #26
0
        //其实就是添加留言
        #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);
            }
        }
Beispiel #27
0
 //查看回复情况
 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);
     }
 }
Beispiel #28
0
 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);
     }
 }
Beispiel #29
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);
     }
 }