public async Task <IActionResult> deleteRatingsAsync([FromBody] UserCred userCred, [FromHeader] string Authorization) { int movieId = userCred.MovieId; string email = tokenObj.GetNameClaims(Authorization); if (!(await RatingMethods.deleteRatingAsync(movieId, email))) { return(NotFound()); } string json = JsonConvert.SerializeObject("200: description: Successfully deleted rating", Formatting.Indented); await DbMethods.dbcloseAsync(); return(Ok(json)); }
public async Task <IActionResult> GetMovieUserRatingsAsync([FromHeader] string Authorization, int movieId, int page) { string email = tokenObj.GetNameClaims(Authorization); Dictionary <string, string> dictionary = new Dictionary <string, string>(); Rating rating = await RatingMethods.getMovieSingleRatingAsync(movieId, email); if (rating == null) { dictionary.Add("Message:", "NotFound"); dictionary.Add("Description:", "Rating not found"); return(NotFound(dictionary)); } await DbMethods.dbcloseAsync(); return(Ok(JsonConvert.SerializeObject(rating, Formatting.Indented))); }
public async Task <IActionResult> GetMovieAverageAsync(int movieId) { Dictionary <string, decimal> retDict = await RatingMethods.getMovieAverageAsync(movieId); if (retDict["percentage"] == -1) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("Message:", "NotFound"); dictionary.Add("Description:", "Ratings not found"); return(NotFound(dictionary)); } string json = JsonConvert.SerializeObject(retDict, Formatting.Indented); await DbMethods.dbcloseAsync(); return(Ok(json)); }
public async Task <IActionResult> GetMovieRatingsAsync([FromHeader] string Authorization, int movieId, int page) { string email = ""; if (Authorization != null) { email = tokenObj.GetNameClaims(Authorization); } Dictionary <string, List <Rating> > dictionary = await RatingMethods.getMovieRatingsAsync(movieId, page, email); if (dictionary["Ratings"].Count == 0 || dictionary == null) { return(NotFound(JsonConvert.SerializeObject("Not found", Formatting.Indented))); } string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented); await DbMethods.dbcloseAsync(); return(Ok(json)); }