public bool Save(Tweet tweet) { using (var dbItem = new TwitterEntities()) { dbItem.Tweets.Attach(tweet); dbItem.Entry(tweet).State = EntityState.Modified; return dbItem.SaveChanges() > 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; } }
public bool Save(User user) { using (var dbContext = new TwitterEntities()) { dbContext.Users.Attach(user); dbContext.Entry(user).State = EntityState.Modified; dbContext.SaveChanges(); return true; } }