예제 #1
0
        public async Task <IActionResult> AddRating(Guid userId, Guid movieId, [FromBody] int rating)
        {
            if (rating == 0 || rating > 5)
            {
                return(BadRequest("Rating must be between 1 and 5"));
            }

            var user = await _userRepository.GetAsync(userId);

            var movie = await _movieRepository.GetAsync(movieId);

            if (user == null || movie == null)
            {
                return(NotFound());
            }

            await _movieRatingRepository.AddAsync(userId, movieId, rating);

            return(Ok());
        }