Example #1
0
 public bool Add(Tweet tweet)
 {
     using (var dbItem = new TwitterEntities())
     {
         dbItem.Tweets.Add(tweet);
         return dbItem.SaveChanges() > 0;
     }
 }
Example #2
0
 public bool Save(Tweet tweet)
 {
     using (var dbItem = new TwitterEntities())
     {
         dbItem.Tweets.Attach(tweet);
         dbItem.Entry(tweet).State = EntityState.Modified;
         return dbItem.SaveChanges() > 0;
     }
 }
Example #3
0
 public bool Add(User user)
 {
     using (var dbContext = new TwitterEntities())
     {
         user.Password = Encryptdata(user.Password);
         dbContext.Users.Add(user);
         if (dbContext.SaveChanges() > 0)
             return true;
         else
             return false;
     }
 }
Example #4
0
 public bool Delete(int id)
 {
     using (var dbItem = new TwitterEntities())
     {
         var _tweet = dbItem.Tweets.Find(id);
         if (!(_tweet).Equals(null))
         {
             dbItem.Tweets.Remove(_tweet);
         }
         return dbItem.SaveChanges() > 0;
     }
 }
Example #5
0
 public bool Activated(string email)
 {
     using (var dbContext = new TwitterEntities())
     {
          var result = dbContext.Users.Where(currentUser => currentUser.Email == email).FirstOrDefault();
          result.Activated = true;
          dbContext.Users.Attach(result);
          dbContext.Entry(result).State = EntityState.Modified;
         if ( dbContext.SaveChanges() > 0)
             return true;
         else
             return false;
     }
 }
Example #6
0
 public bool Delete(int id)
 {
     using (var dbContext = new TwitterEntities())
     {
         var userToDelete = dbContext.Users.FirstOrDefault(currentUser => currentUser.id_user == id);
         var tweetToDelete =
             from tweet in dbContext.Tweets
             where tweet.id_user == id
             select tweet;
         foreach(var tweet in tweetToDelete){
         dbContext.Tweets.Remove(tweet);
         }
         dbContext.Users.Remove(userToDelete);
         if (dbContext.SaveChanges() > 0)
             return true;
         else
             return false;
     }
 }
Example #7
0
 public bool Save(User user)
 {
     using (var dbContext = new TwitterEntities())
     {
         dbContext.Users.Attach(user);
         dbContext.Entry(user).State = EntityState.Modified;
         dbContext.SaveChanges();
         return true;
     }
 }