Exemple #1
0
        public bool Save(SysLog log)
        {
            BADBContext db = new BADBContext();

            db.SysLogs.Add(log);
            return(db.SaveChanges() > 0);
        }
Exemple #2
0
        public bool Save(Activity a)
        {
            BADBContext db = new BADBContext();

            db.Activities.Add(a);
            return(db.SaveChanges() > 0);
        }
Exemple #3
0
        public bool Save(Member m)
        {
            BADBContext db = new BADBContext();

            db.Members.Add(m);
            return(db.SaveChanges() > 0);
        }
Exemple #4
0
        public bool DeleteJoinInfo(Guid ActivityID, string MemberAlias)
        {
            BADBContext db   = new BADBContext();
            var         info = db.ActivityJoinInfos.Where(r => r.MemberAlias == MemberAlias && r.ActivityID == ActivityID).FirstOrDefault();

            db.ActivityJoinInfos.Remove(info);
            return(db.SaveChanges() > 0);
        }
Exemple #5
0
        public bool Delete(Guid ActivityID)
        {
            BADBContext db   = new BADBContext();
            var         info = db.Activities.Where(r => r.ID == ActivityID).FirstOrDefault();

            db.Activities.Remove(info);
            return(db.SaveChanges() > 0);
        }
Exemple #6
0
        public bool Delete(Guid memberID)
        {
            BADBContext db   = new BADBContext();
            var         info = db.Members.Where(r => r.ID == memberID).FirstOrDefault();

            db.Members.Remove(info);
            return(db.SaveChanges() > 0);
        }
Exemple #7
0
        public bool SaveLikeInfo(ActivityLikeInfo info)
        {
            BADBContext db = new BADBContext();

            if (db.ActivityLikeInfos.Where(r => r.MemberAlias == info.MemberAlias && r.ActivityID == info.ActivityID).Count() > 0)
            {
                return(true);
            }

            db.ActivityLikeInfos.Add(info);
            return(db.SaveChanges() > 0);
        }
Exemple #8
0
 public void Edit(Member m)
 {
     using (BADBContext db = new BADBContext())
     {
         var old = db.Members.Where(r => r.ID == m.ID).FirstOrDefault();
         if (null != old)
         {
             old.DisplayName = m.DisplayName;
             old.AvantarPath = m.AvantarPath;
             old.CreateDate  = DateTime.UtcNow.AddHours(8);
         }
         db.SaveChanges();
     }
 }
Exemple #9
0
 public void Edit(ActivityType at)
 {
     using (BADBContext db = new BADBContext())
     {
         var old = db.ActivityTypes.Where(r => r.ID == at.ID).FirstOrDefault();
         if (null != old)
         {
             old.Name             = at.Name;
             old.Description      = at.Description;
             old.PosterImagePath1 = at.PosterImagePath1;
             old.CreateDate       = DateTime.UtcNow.AddHours(8);
         }
         db.SaveChanges();
     }
 }
Exemple #10
0
        public bool Save(ActivityType a)
        {
            BADBContext db = new BADBContext();

            var maxRank = db.ActivityTypes.Max(r => r.Rank);

            if (null == maxRank)
            {
                maxRank = 0;
            }
            a.Rank       = ++maxRank;
            a.CreateDate = DateTime.UtcNow.AddHours(8);

            db.ActivityTypes.Add(a);
            return(db.SaveChanges() > 0);
        }
Exemple #11
0
 public void Edit(Activity activity)
 {
     using (BADBContext db = new BADBContext())
     {
         var old = db.Activities.Where(r => r.ID == activity.ID).FirstOrDefault();
         if (null != old)
         {
             old.Name           = activity.Name;
             old.StartDateTime  = activity.StartDateTime;
             old.EndDateTime    = activity.EndDateTime;
             old.Detail         = activity.Detail;
             old.ActivityTypeID = activity.ActivityTypeID;
             old.Address        = activity.Address;
         }
         db.SaveChanges();
     }
 }
Exemple #12
0
        public bool Up(Guid activityTypeID)
        {
            BADBContext db      = new BADBContext();
            var         maxRank = db.ActivityTypes.Max(r => r.Rank);
            var         cur     = db.ActivityTypes.Where(r => r.ID == activityTypeID).FirstOrDefault();

            if (cur.Rank == maxRank)
            {
                return(true);
            }
            var previous = db.ActivityTypes.Where(r => r.Rank == cur.Rank + 1).FirstOrDefault();

            int?curRank = cur.Rank;

            cur.Rank      = previous.Rank;
            previous.Rank = curRank;

            return(db.SaveChanges() > 0);
        }
Exemple #13
0
        public bool Down(Guid activityTypeID)
        {
            BADBContext db      = new BADBContext();
            var         minRank = db.ActivityTypes.Min(r => r.Rank);
            var         cur     = db.ActivityTypes.Where(r => r.ID == activityTypeID).FirstOrDefault();

            if (cur.Rank == minRank)
            {
                return(true);
            }

            var next = db.ActivityTypes.Where(r => r.Rank == cur.Rank - 1).FirstOrDefault();

            int?curRank = cur.Rank;

            cur.Rank  = next.Rank;
            next.Rank = curRank;

            return(db.SaveChanges() > 0);
        }