public List <PostTweetsUsers> sprofiltweet(int id)
        {
            var user = GetDtoUserbyId(id);

            List <PostTweetsUsers> ptu = new List <PostTweetsUsers>();

            var gelen = context.Post.Where(x => x.UserID == id)
                        .Include(x => x.Likes)
                        .Include(x => x.Shares).
                        Include(x => x.Comments)
                        .ToList();

            foreach (var posts in gelen)
            {
                PostTweetsUsers post = new PostTweetsUsers();
                post.Likeactive  = posts.Likes.Any(x => x.UserId == id && x.PostId == posts.Id && x.IsDeleted == false);
                post.Shareactive = posts.Likes.Any(x => x.UserId == id && x.PostId == posts.Id && x.IsDeleted == false);
                post.UserId      = user.UserId;
                post.Name        = user.FullName;
                post.useractive  = user.IsActive;
                post.userdelete  = user.IsDeleted;
                post.Postid      = posts.Id;
                post.ProfilPhoto = user.ProfilPhoto;
                post.PostPhoto   = posts.Photo;
                post.Text        = posts.Description;
                post.Createddate = posts.CreatedDate;
                post.LikeCount   = posts.Likes.Where(x => x.IsDeleted == false && x.IsActive == true).Count();
                post.ShareCount  = posts.Likes.Where(x => x.IsDeleted == false && x.IsActive == true).Count();
                post.ReplyCount  = posts.Comments.Where(x => x.IsDeleted == false && x.IsActive == true).Count();
                ptu.Add(post);
            }

            return(ptu.OrderByDescending(x => x.Createddate).ToList());
        }
        public List <PostTweetsUsers> GetFriendsConn(int id)
        {
            List <DtoUser> userid = new List <DtoUser>();

            var result1 = context.connections.Where(x => x.UserIdOne == id && x.IsActive == true).ToList();

            foreach (var item in result1)
            {
                DtoUser user1 = new DtoUser();
                user1.UserId = item.UserIdTwo;
                userid.Add(user1);
            }
            var result2 = context.connections.Where(x => x.UserIdTwo == id && x.IsActive == true).ToList();

            foreach (var item in result2)
            {
                DtoUser user2 = new DtoUser();
                user2.UserId = item.UserIdOne;
                userid.Add(user2);
            }
            DtoUser user = new DtoUser();

            user.UserId = id;
            userid.Add(user);


            List <DtoUser> users = new List <DtoUser>();

            foreach (var item in userid)
            {
                DtoUser user3 = new DtoUser();
                user3 = userM.GetDtoUserbyId(item.UserId);
                users.Add(user3);
            }

            List <PostTweetsUsers> ptu = new List <PostTweetsUsers>();

            foreach (var item in users)
            {
                var gelen = context.Post.Where(x => x.UserID == item.UserId)
                            .Include(x => x.Likes)
                            .Include(x => x.Shares).
                            Include(x => x.Comments)
                            .ToList();

                foreach (var posts in gelen)
                {
                    List <DtoComment> commenDtoList = new List <DtoComment>();
                    PostTweetsUsers   post          = new PostTweetsUsers();
                    post.Likeactive  = posts.Likes.Any(x => x.IsActive == true);
                    post.Shareactive = posts.Shares.Any(x => x.IsActive == true);
                    post.UserId      = item.UserId;
                    post.Name        = item.FullName;
                    post.useractive  = item.IsActive;
                    post.userdelete  = item.IsDeleted;
                    post.Postid      = posts.Id;
                    post.ProfilPhoto = item.ProfilPhoto;
                    post.PostPhoto   = posts.Photo;
                    post.Text        = posts.Description;
                    post.Createddate = posts.CreatedDate;
                    post.LikeCount   = posts.Likes.Where(x => x.IsDeleted == false && x.IsActive == true).Count();
                    post.ShareCount  = posts.Likes.Where(x => x.IsDeleted == false && x.IsActive == true).Count();
                    post.ReplyCount  = posts.Comments.Where(x => x.IsDeleted == false && x.IsActive == true).Count();


                    var result = context.comments.Where(x => x.PostId == posts.Id).ToList();
                    if (result != null)
                    {
                        foreach (var item2 in result)
                        {
                            DtoComment comment = new DtoComment();

                            comment.Description = item2.Description;
                            comment.UserId      = item2.UserId;
                            comment.PostId      = item2.PostId;
                            comment.IsActive    = item2.IsActive;
                            comment.IsDeleted   = item2.IsDeleted;
                            comment.Photo       = userM.GetDtoUserbyId(item2.UserId).ProfilPhoto;
                            comment.Fullname    = userM.GetDtoUserbyId(item2.UserId).FullName;

                            commenDtoList.Add(comment);
                        }
                    }
                    post.comments = commenDtoList;
                    ptu.Add(post);
                }
            }
            return(ptu.OrderByDescending(x => x.Createddate).ToList());
        }