public UserComments GetUserComments(int id)
        {
            User user  = this.userRepository.GetById(id);
            var  posts = this.postRepository.GetPostsByUserId(user.Id);


            IList <Comment> comments = this.commentRepository.GetAll();

            IEnumerable <int> postsB = from post in posts
                                       select post.Id;

            // IList<int> postsB = posts.Select(u => u.Id).ToList();


            var comm = from comment in comments
                       where postsB.Contains(comment.PostId)
                       select comment;
            UserComments result = new UserComments
            {
                User     = user,
                Comments = comm.ToList(),
            };


            return(result);
        }
Esempio n. 2
0
        public UserComments GetUserComments(int id)
        {
            var user     = this.userRepository.GetById(id);
            var comments = this.commentRepository.GetAll();
            var response = new UserComments
            {
                User     = user,
                Comments = comments.Where(c => c.UserId == user.Id).ToList()
            };

            return(response);
        }
Esempio n. 3
0
        public UserComments GetCommentsPerUser(int id)
        {
            var comments = new UserComments();

            var user = this.userRepository.GetById(id);

            comments.Name = user.Name;

            var comms = this.commentRepository.GetCommentsByUserId(user.Id);

            foreach (var comm in comms)
            {
                comments.Comments.Add(comm.Id, comm.Text);
            }

            return(comments);
        }
Esempio n. 4
0
        public List <UserComments> GetUserComents(int id)
        {
            var comments = new List <UserComments>();
            var comment  = new UserComments();


            var userComment = this.commentRepository.GetCommentByUserId(id);

            foreach (var item in userComment)
            {
                comment.Comment = item.Text;
                comments.Add(comment);
            }


            return(comments);
        }