public IHttpActionResult Dislike([FromUri] string AccessToken, [FromUri] string PostId) { var UserId = TokenValidator.VerifyToken(AccessToken); var PostDisliked = PostAuxiliar.PostById(PostId); if (PostDisliked.Dislikes.Contains(UserId)) { PostDisliked.Dislikes.Remove(UserId); } else { PostDisliked.Dislikes.Add(UserId); } if (PostDisliked.Likes.Contains(UserId)) { PostDisliked.Likes.Remove(UserId); } var Update = Builders <Post> .Update .Set("Likes", PostDisliked.Likes) .Set("Dislikes", PostDisliked.Dislikes); PostAuxiliar.UpdatePostById(PostDisliked.Id, Update); int TotalLikes = PostDisliked.Likes.Count; int TotalDeslikes = PostDisliked.Dislikes.Count; dynamic Response = new { TotalLikes, TotalDeslikes }; return(Ok(Response)); }
public IHttpActionResult PostById([FromUri] string PostId) { var Post = PostAuxiliar.PostById(PostId); Post = PostAuxiliar.UpdateOwner(Post, SQLContext); return(Ok(Post)); }
private Post FindParent(Post NewPost) { var ParentPost = PostAuxiliar.PostById(NewPost.Parent); return(ParentPost); }