public int SuspendUser(int userId, bool suspend = true)
 {
     using (var context = new appsterEntities())
     {
         var dbUser = context.users.SingleOrDefault(i => i.id == userId);
         if(dbUser!=null) 
         {
             dbUser.status = suspend ? 0 : 1;
             context.SaveChanges();
             return dbUser.status;
         }
         throw new AppsDataNotFoundException();
     }
 }
        public void DeleteUser(Func<user, bool> predicate)
        {
            using (var context = new appsterEntities())
            {
                context.Configuration.AutoDetectChangesEnabled = false;
                var users = context.users.Where(predicate);
                try
                {
                    if (users.Count() > 0)
                    {
                        context.users.RemoveRange(users);
                    }
                }
                finally
                {
                    context.Configuration.AutoDetectChangesEnabled = true;
                    context.SaveChanges();
                }

            }
        }
 public void SuspendUser(Func<user, bool> predicate)
 {
     using (var context = new appsterEntities())
     {
         context.Configuration.AutoDetectChangesEnabled = false;
         var users = context.users.Where(predicate);
         try
         {
             foreach (var usr in users)
             {
                 usr.status = usr.status == 0 ? 1 : 0;
                 context.Entry(usr).State = System.Data.Entity.EntityState.Modified;
             }
         }
         finally
         {
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
 }
 public int SuspendGift(int giftId, bool suspend = true)
 {
     using (var context = new appsterEntities())
     {
         var dbGift = context.gifts.SingleOrDefault(i => i.id == giftId);
         if (dbGift != null)
         {
             dbGift.status = suspend ? 0 : 1;
             context.SaveChanges();
             return dbGift.status;
         }
         throw new AppsDataNotFoundException();
     }
 }