public IActionResult AddUserReviewByBookId(int userId, int bookId, [FromBody] BookReviewViewModel newReview)
 {
     if (newReview == null)
     {
         return(BadRequest());
     }
     if (!ModelState.IsValid)
     {
         return(StatusCode(412));
     }
     try
     {
         var response = _reviewsService.AddReview(userId, bookId, newReview);
         return(Ok(response));
     }
     catch (UserNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (BookNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (AlreadyReviewedByUserException e)
     {
         return(NotFound(e.Message));
     }
 }
Exemple #2
0
 public IActionResult AddReview(AddReviewDTO reviewObject)
 {
     _reviewsService.AddReview(reviewObject);
     return(Ok());
 }
        public IActionResult AddReview([FromBody] ReviewDto review)
        {
            var newReview = _reviewsService.AddReview(User.Identity.GetClaim("name"), review);

            return(Ok(newReview));
        }