public IActionResult WriteReview([FromBody] WriteReviewRequestDto body) { var errors = body.Validate(); if (errors != null) { return(BadRequest(errors)); } // Authorize user long authorId = int.Parse(User.Claims.First(x => x.Type == "uid").Value); if (body.author != authorId) { return new ObjectResult(new ForbiddenDto()) { StatusCode = 403 } } ; // Check is user with this id exists in db if (!_userService.IsUserExists(authorId)) { return(BadRequest(new ValidateErrorDto(new ValidateErrorElement( "author", "NotFound", "user with this id not found" )))); } // check is movie with this id exists in db if (!_movieServices.Exists(body.movie)) { return(BadRequest(new ValidateErrorDto(new ValidateErrorElement( "movie", "NotFound", "movie with this id not found" )))); } // Write review _movieServices.WriteReview(body.movie, body.ToDomain()); return(Ok(new EmptyOkDto())); } }