Example #1
0
        public static List <TweetDto.DtoTweet> GetTweets(int followingId)
        {
            var oldTweet = new List <TweetDto.DtoTweet>();

            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    var Ucontent = (from tweets in context.Tweets
                                    where tweets.UserDetailId == followingId
                                    select tweets).ToList();

                    Ucontent.ForEach(y =>
                    {
                        oldTweet.Add(new TweetDto.DtoTweet()
                        {
                            TweetContent = y.TweetContent
                        });
                    });

                    return(oldTweet);
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
            }
            return(oldTweet);
        }
Example #2
0
        public static bool AddToHashTagList(IList <DtoHashTag> listOFHashTags)
        {
            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    foreach (DtoHashTag hashtag in listOFHashTags)
                    {
                        HashTag newHashtag = context.HashTags.FirstOrDefault(a => a.HashTagName == hashtag.HashTagName);

                        context.HashTags.Add(new HashTag
                        {
                            HashTagName = newHashtag.HashTagName,
                            TweetId     = newHashtag.TweetId
                        });
                    }
                    context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #3
0
 public static TweetDto.DtoTweet AddTweet(TweetDto.DtoTweet tweetObject)
 {
     TweetDto.DtoTweet newTweet = null;
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             Tweet tweet = new Tweet
             {
                 TweetContent = tweetObject.TweetContent,
                 UserDetailId = tweetObject.UserDetailId,
                 Date         = tweetObject.Date
             };
             context.Tweets.Add(tweet);
             if (context.SaveChanges() > 0)
             {
                 newTweet = tweetObject;
             }
         }
     }
     catch (Exception e)
     {
         Console.Write(e);
     }
     return(newTweet);
 }
Example #4
0
        public static DtoUserFollower AddFollower(DtoUserFollower userTrack)
        {
            DtoUserFollower newFollowee = new DtoUserFollower();

            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    UserFollower followee = new UserFollower
                    {
                        FollowerId   = userTrack.FollowerId,
                        UserDetailId = userTrack.UserDetailId
                    };
                    context.UserFollowers.Add(followee);
                    context.SaveChanges();

                    {
                        newFollowee.UserDetailId = followee.UserDetailId;
                        newFollowee.FollowerId   = followee.FollowerId;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(newFollowee);
        }
Example #5
0
        public static IList <UserDetailDto.UserData> GetFollowers(int ucid)
        {
            var list = new List <UserDetailDto.UserData>();

            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    var list1 = (from userConnection in context.UserFollowers
                                 where userConnection.UserDetailId == ucid
                                 select userConnection).ToList();
                    list1.ForEach(item =>
                    {
                        list.Add(new UserDetailDto.UserData()
                        {
                            UserDetailId = item.FollowerId,
                            FirstName    = item.UserDetail.FirstName,
                            Image        = item.UserDetail.Image
                        });
                    });
                }
            }
            catch (Exception)
            {
            }
            return(list);
        }
Example #6
0
        public static Login GetUserInfo(Login login)
        {
            Login UserInfo = null;

            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    var user = (from users in context.UserDetails
                                where users.Email == login.Email &&
                                users.Password == login.Password
                                select users).FirstOrDefault();

                    if (user != null)
                    {
                        UserInfo = new Login
                        {
                            Email    = user.Email,
                            Password = user.Password
                        };
                    }
                    else
                    {
                        UserInfo = null;
                    }
                }
            }
            catch (NullReferenceException)
            {
                UserInfo = null;
            }

            return(UserInfo);
        }
Example #7
0
        public static Register AddUser(Register register)
        {
            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    UserDetail user = new UserDetail
                    {
                        Email        = register.Email,
                        Password     = register.Password,
                        FirstName    = register.FirstName,
                        LastName     = register.LastName,
                        Image        = Enumerable.Repeat((byte)0x20, 10).ToArray(),
                        MobileNumber = register.MobileNumber,
                        Country      = register.Country
                    };
                    context.UserDetails.Add(user);
                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
                throw (e);
            }

            return(register);
        }
Example #8
0
 public static int GetUserDetailId(string emailId)
 {
     using (GlitterDBEntities1 context = new GlitterDBEntities1())
     {
         var userDetailId = (from e in context.UserDetails select e).Where(x => x.Email.Equals(emailId)).FirstOrDefault().UserDetailId;
         return(userDetailId);
     }
 }
Example #9
0
 public static IList <string> SearchUser(string searchString)
 {
     using (GlitterDBEntities1 context = new GlitterDBEntities1())
     {
         var Fname = (from users in context.UserDetails
                      where users.FirstName == searchString
                      select users.FirstName).ToList();
         if (Fname == null)
         {
             return(null);
         }
         else
         {
             return(Fname);
         }
     }
 }
Example #10
0
 public static bool IfEmailIsUnique(string email)
 {
     using (GlitterDBEntities1 context = new GlitterDBEntities1())
     {
         var emailid = (from users in context.UserDetails
                        where users.Email == email
                        select users.Email).FirstOrDefault();
         if (emailid == null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Example #11
0
 public static bool DeleteTweet(TweetDto.DtoTweet tweettoDelete)
 {
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             var tweet = context.Tweets.Find(tweettoDelete.TweetId);
             context.Tweets.Remove(tweet);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #12
0
 public static TweetDto.DtoTweet EditTweet(TweetDto.DtoTweet editedTweet)
 {
     TweetDto.DtoTweet newtweet = null;
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             var tweet = context.Tweets.Find(editedTweet.TweetId);
             tweet.TweetContent = editedTweet.TweetContent;
             tweet.Date         = editedTweet.Date;
             context.SaveChanges();
         }
     }
     catch (Exception)
     {
     }
     return(newtweet);
 }
Example #13
0
 public static bool ReamoveReaction(UserReactionDto.DtoUserReaction reactionObject)
 {
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             //var react = context.Reacts.Find(reactObject.Id);
             var react = context.UserReactions.FirstOrDefault(l => l.UserReactionId == reactionObject.UserReactionId && l.UserDetailId == reactionObject.UserDetailId);
             context.UserReactions.Remove(react);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #14
0
        public static int NoOfDisLikes(int tweetid)
        {
            int count = 0;

            try
            {
                using (GlitterDBEntities1 context = new GlitterDBEntities1())
                {
                    count = (from reactions in context.UserReactions
                             where reactions.UserReactionId == tweetid && reactions.IsLiked == -1
                             select reactions.UserReactionId).ToList().Count;
                }
            }
            catch (Exception)
            {
            }
            return(count);
        }
Example #15
0
 public static bool CheckUserLoggedIn(string emailId, string password)
 {
     using (GlitterDBEntities1 context = new GlitterDBEntities1())
     {
         var emailCheck = (from users in context.UserDetails
                           where users.Email == emailId
                           select users.Email).ToList();
         var passwordCheck = (from users in context.UserDetails
                              where users.Password == password
                              select users.Password).ToList();
         if (emailCheck.Count() != 0 && passwordCheck.Count() != 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Example #16
0
 public static bool AddToDislikes(UserReactionDto.DtoUserReaction reactionObject)
 {
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             context.UserReactions.Add(new UserReaction
             {
                 UserReactionId = reactionObject.UserReactionId,
                 UserDetailId   = reactionObject.UserDetailId,
                 IsLiked        = 1
             });
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #17
0
 public static bool UnFollow(DtoUserFollower followee)
 {
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             var following = (from followings in context.UserFollowers
                              where followings.FollowerId == followee.FollowerId &&
                              followings.UserDetailId == followee.UserDetailId
                              select followings).FirstOrDefault();
             if (following == null)
             {
                 return(false);
             }
             context.UserFollowers.Remove(following);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #18
0
 public static bool DeleteFromHashTagList(IList <DtoHashTag> listOFHashTags)
 {
     try
     {
         using (GlitterDBEntities1 context = new GlitterDBEntities1())
         {
             foreach (DtoHashTag hashtag in listOFHashTags)
             {
                 HashTag newHashtag = context.HashTags.FirstOrDefault(a => a.HashTagName == hashtag.HashTagName && a.TweetId == hashtag.TweetId);
                 //if a hashtag already exists
                 if (newHashtag != null)
                 {
                     context.HashTags.Remove(newHashtag);
                 }
                 context.SaveChanges();
             }
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }