public async Task update_comment_likeAsync(string post_id, string comment_id, string emo, int value) { var post_comments_collection = dataContext.getConnection().GetCollection <Post_Comment>("Post_Comment"); var filter = Builders <Post_Comment> .Filter.And( Builders <Post_Comment> .Filter.Where(x => x.post_id == ObjectId.Parse(post_id)), Builders <Post_Comment> .Filter.Eq("comments._id", ObjectId.Parse(comment_id))); CommentManagement cm = new CommentManagement(); Comment c = cm.getComment(post_id, comment_id); var update = Builders <Post_Comment> .Update.Set("comments.$." + emo, getEmojiCount(c, emo) + value); await post_comments_collection.FindOneAndUpdateAsync(filter, update); }
public async Task removeSubPost(string post_id, string sub_post_id) { PostLikeManagement plm = new PostLikeManagement(); CommentManagement cm = new CommentManagement(); var post_collection = dataContext.getConnection().GetCollection <Post>("Post"); var filter = Builders <Post> .Filter.Eq("_id", ObjectId.Parse(post_id)); var update = Builders <Post> .Update.PullFilter("video_image", Builders <Post> .Filter.Eq("_id", ObjectId.Parse(sub_post_id))); await post_collection.UpdateOneAsync(filter, update); await plm.remove_post_like(sub_post_id); await cm.remove_post_comment(sub_post_id); }