public UpdateReviewRating ( string reviewId, string rating ) : bool | ||
reviewId | string | |
rating | string | |
return | bool |
// get : api/ReviewRating?movieid=<mid>&reviewid=<rid>&rating=<rating> protected override string ProcessRequest() { // get query string parameters string queryParameters = this.Request.RequestUri.Query; try { if (queryParameters != null) { var qpParams = HttpUtility.ParseQueryString(queryParameters); if (!string.IsNullOrEmpty(qpParams["movieid"]) && !string.IsNullOrEmpty(qpParams["reviewid"]) && !string.IsNullOrEmpty(qpParams["rating"])) { string movieId = qpParams["movieid"].ToString(); string reviewId = qpParams["reviewid"].ToString(); string rating = qpParams["rating"].ToString(); var tableMgr = new TableManager(); bool result = tableMgr.UpdateReviewRating(reviewId, rating); if (!result) { return jsonSerializer.Value.Serialize(new { Status = "Error", UserMessage = "Could not save the review rating", ActualError = "Unknown" }); } else { // Update the movie rating } return jsonSerializer.Value.Serialize(new { Status = "Ok", UserMessage = "Successfully saved the rating" }); } } } catch (Exception ex) { return jsonSerializer.Value.Serialize(new { Status = "Error", UserMessage = "Unable to save the review rating", ActualError = ex.Message }); } return jsonSerializer.Value.Serialize(new { Status = "Error", UserMessage = "Unable to save the review rating", ActualError = "Some of the parameters is empty" }); }