public async Task <IActionResult> UpdateLikes([FromBody] LikesDTO commentInfo)
        {
            bool updated = await _commentsRepository.UpdateLikes(commentInfo.CommentId, commentInfo.UserId, commentInfo.Like);

            if (!updated)
            {
                return(BadRequest(new { message = "Failed to update likes" }));
            }

            return(Ok(new { message = "Likes updated" }));
        }
Ejemplo n.º 2
0
        public void UnLike(int post_id, LikesDTO like)
        {
            try
            {
                var client       = new MongoClient(connectionString);
                var db           = client.GetDatabase("Social_Network");
                var posts        = db.GetCollection <PostsDTO>("Posts");
                var UpdateFilter = Builders <PostsDTO> .Update.Pull("Likes", like);

                posts.UpdateOne(g => g.Post_Id == post_id, UpdateFilter);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }