TMDbLib/Client/TMDbClientMovies.cs
/// <summary>
/// Change the rating of a specified movie.
/// </summary>
/// <param name="movieId">The id of the movie to rate</param>
/// <param name="rating">The rating you wish to assign to the specified movie. Value needs to be between 0.5 and 10 and must use increments of 0.5. Ex. using 7.1 will not work and return false.</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>True if the the movie's rating was successfully updated, false if not</returns>
/// <remarks>Requires a valid guest or user session</remarks>
/// <exception cref="GuestSessionRequiredException">Thrown when the current client object doens't have a guest or user session assigned.</exception>
Change the rating of a specified movie.
Change the rating of a specified movie .
public async Task<bool> MovieSetRatingAsync(int movieId, double rating, CancellationToken cancellationToken = default)
        {
            RequireSessionId(SessionType.GuestSession);
            RestRequest req = _client.Create("movie/{movieId}/rating");
            req.AddUrlSegment("movieId", movieId.ToString(CultureInfo.InvariantCulture));
            AddSessionId(req);
            req.SetBody(new { value = rating });
            RestResponse<PostReply> response = await req.Post<PostReply>(cancellationToken).ConfigureAwait(false);
            PostReply item = await response.GetDataObject().ConfigureAwait(false);
            return item.StatusCode == 1 || item.StatusCode == 12;
        }
public async Task < bool > MovieSetRatingAsync ( int movieId , double rating , CancellationToken cancellationToken = default ) { RequireSessionId ( SessionType . GuestSession ) ; RestRequest req = _client . Create ( " " ) ; req . AddUrlSegment ( " " , movieId . ToString ( CultureInfo . InvariantCulture ) ) ; AddSessionId ( req ) ; req . SetBody ( new { value = rating } ) ; RestResponse < PostReply > response = await req . Post < PostReply > ( cancellationToken ) . ConfigureAwait ( false ) ; PostReply item = await response . GetDataObject ( ) . ConfigureAwait ( false ) ; return item . StatusCode == 1 || item . StatusCode == 12 ; }
Change the rating of a specified movie.
Change the rating of a specified movie .
// status code 1 = "Success" // status code 12 = "The item/record was updated successfully" - Used when an item was previously rated by the user // TODO: Previous code checked for item=null
True if the the movie's rating was successfully updated, false if not
True if the the movie ' s rating was successfully updated false if not
Thrown when the current client object doens't have a guest or user session assigned.
Thrown when the current client object doens ' t have a guest or user session assigned .
movieId
int
The id of the movie to rate
The id of the movie to rate
rating
double
The rating you wish to assign to the specified movie. Value needs to be between 0.5 and 10 and must use increments of 0.5. Ex. using 7.1 will not work and return false.
The rating you wish to assign to the specified movie . Value needs to be between 0 . 5 and 10 and must use increments of 0 . 5 . Ex . using 7 . 1 will not work and return false .
cancellationToken
CancellationToken
A cancellation token
A cancellation token
remarks
Requires a valid guest or user session
Requires a valid guest or user session