Exemplo n.º 1
0
        public List <Activity> GetByPage(string sortOrder, string searchString)
        {
            BADBContext db = new BADBContext();

            var activities = from a in db.Activities
                             select a;

            if (!String.IsNullOrEmpty(searchString))
            {
                activities = activities.Where(s => s.Name.Contains(searchString) ||
                                              s.Detail.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name_desc":
                activities = activities.OrderByDescending(s => s.Name);
                break;

            case "Date":
                activities = activities.OrderBy(s => s.StartDateTime);
                break;

            case "date_desc":
                activities = activities.OrderByDescending(s => s.StartDateTime);
                break;

            default:
                activities = activities.OrderByDescending(s => s.Name);
                break;
            }

            return(activities.ToList());
        }
Exemplo n.º 2
0
        public bool Save(SysLog log)
        {
            BADBContext db = new BADBContext();

            db.SysLogs.Add(log);
            return(db.SaveChanges() > 0);
        }
Exemplo n.º 3
0
 public IList <Activity> GetByCondition(Func <Activity, bool> condition)
 {
     using (BADBContext db = new BADBContext())
     {
         return(db.Activities.Where(condition).ToList());
     }
 }
Exemplo n.º 4
0
 public IList <Member> GetByCondition(Func <Member, bool> condition)
 {
     using (BADBContext db = new BADBContext())
     {
         return(db.Members.Where(condition).ToList());
     }
 }
Exemplo n.º 5
0
        public bool Save(Activity a)
        {
            BADBContext db = new BADBContext();

            db.Activities.Add(a);
            return(db.SaveChanges() > 0);
        }
Exemplo n.º 6
0
        public bool Save(Member m)
        {
            BADBContext db = new BADBContext();

            db.Members.Add(m);
            return(db.SaveChanges() > 0);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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();
     }
 }
Exemplo n.º 12
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();
     }
 }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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();
     }
 }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public List <Activity> GetAll()
        {
            BADBContext db = new BADBContext();

            return(db.Activities.OrderByDescending(r => r.StartDateTime).ThenByDescending(r => r.CreateDate).ToList());
        }
Exemplo n.º 18
0
        public IEnumerable <Member> GetAll()
        {
            BADBContext db = new BADBContext();

            return(db.Members.OrderByDescending(r => r.CreateDate).ToList());
        }
Exemplo n.º 19
0
        public List <ActivityLikeInfo> GetAllLikeInfo(Guid ActivityID)
        {
            BADBContext db = new BADBContext();

            return(db.ActivityLikeInfos.Where(r => r.ActivityID == ActivityID).ToList());
        }
Exemplo n.º 20
0
        public IEnumerable <ActivityType> GetAll()
        {
            BADBContext db = new BADBContext();

            return(db.ActivityTypes.OrderByDescending(r => r.Rank).ToList());
        }
Exemplo n.º 21
0
        public bool Exists(string domainAlias)
        {
            BADBContext db = new BADBContext();

            return(db.Members.Where(r => r.Alias.Equals(domainAlias)).Count() > 0);
        }