Ejemplo n.º 1
0
        public IEnumerable <Tweet> GetAllTweets()
        {
            List <Tweet> objTweets = new List <Tweet>();

            try
            {
                using (MVCSBAEntities objcontext = new MVCSBAEntities())
                {
                    var tweets = from obj in objcontext.Tweets

                                 select obj;

                    foreach (var item in tweets)
                    {
                        objTweets.Add(new Tweet {
                            userid = item.userid, TweetID = item.TweetID, message = item.message, created = item.created
                        });
                    }
                }
                return(objTweets);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <Tweet> ViewTweetsByUsername(string username)
        {
            List <Tweet> objTweets = new List <Tweet>();

            try
            {
                using (MVCSBAEntities objcontext = new MVCSBAEntities())
                {
                    var Query = from obj in objcontext.Tweets
                                where obj.userid == username
                                select new
                    {
                        obj.message
                    };
                    foreach (var item in Query)
                    {
                        objTweets.Add(new Tweet {
                            message = item.message
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(objTweets);
        }
Ejemplo n.º 3
0
 public void AddTweet(Tweet objTweet)
 {
     try
     {
         using (var objcontext = new MVCSBAEntities())
         {
             objcontext.Tweets.Add(objTweet);
             objcontext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public void AddUser(Person objUser)
 {
     try
     {
         using (var objcontext = new MVCSBAEntities())
         {
             objcontext.Persons.Add(objUser);
             objcontext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 5
0
 public void EditTweet(Tweet objTweet)
 {
     try
     {
         using (MVCSBAEntities objcontext = new MVCSBAEntities())
         {
             objcontext.Tweets.Attach(objTweet);
             objcontext.Entry(objTweet).State = System.Data.Entity.EntityState.Modified;
             objcontext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 6
0
 public Tweet FindTweet(int id)
 {
     try
     {
         using (MVCSBAEntities objcontext = new MVCSBAEntities())
         {
             var Query = (from obj in objcontext.Tweets
                          where obj.TweetID == id
                          select obj).FirstOrDefault();
             return(Query);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 7
0
 public void DeleteTweet(int id)
 {
     try
     {
         using (MVCSBAEntities objcontext = new MVCSBAEntities())
         {
             var Query = (from obj in objcontext.Tweets
                          where obj.TweetID == id
                          select obj).FirstOrDefault();
             objcontext.Tweets.Remove(Query);
             objcontext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
        public bool VerifyUser(string Username, string Password)
        {
            bool IsvalidUser = false;

            try
            {
                using (var objcontext = new MVCSBAEntities())
                {
                    var NoOfusers = (from obj in objcontext.Persons
                                     where obj.userid == Username && obj.password == Password
                                     select obj).Count();
                    IsvalidUser = NoOfusers > 0;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(IsvalidUser);
        }