public void AddTweet(Tweet objTweet) { try { using (TweetContext objContext = new TweetContext()) { objContext.Tweets.Add(objTweet); objContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void AddUser(Client objUser) { try { using (TweetContext objContext = new TweetContext()) { objContext.Clients.Add(objUser); objContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void EditTweet(Tweet objTweet) { try { using (TweetContext objContext = new TweetContext()) { objContext.Tweets.Attach(objTweet); objContext.Entry(objTweet).State = System.Data.Entity.EntityState.Modified; objContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public Tweet FindTweet(int id) { try { using (TweetContext objContext = new TweetContext()) { var query = (from obj in objContext.Tweets where obj.tweet_id == id select obj).FirstOrDefault(); return(query); } } catch (Exception ex) { throw ex; } }
public void DeleteTweet(int id) { try { using (TweetContext objContext = new TweetContext()) { var query = (from obj in objContext.Tweets where obj.tweet_id == id select obj).FirstOrDefault(); objContext.Tweets.Remove(query); objContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public bool VerifyUser(string username, string password) { try { using (TweetContext objContext = new TweetContext()) { var NoOfUsers = (from obj in objContext.Clients where obj.user_id == username && obj.password == password select obj).Count(); if (NoOfUsers > 0) { return(true); } else { return(false); } } } catch (Exception ex) { throw ex; } }