Example #1
0
        public async Task <IActionResult> SaveImdbRating([FromRoute] string movieId, [FromBody] ImdbForSave imdbForSave)
        {
            var request = new Services.SaveImdbRatingRequest
            {
                Imdb    = _mapper.Map <Services.Imdb>(imdbForSave),
                MovieId = movieId
            };

            await _movieService.SaveImdbRatingAsync(request);

            return(NoContent());
        }
Example #2
0
        public override async Task <Services.SaveImdbRatingResponse> SaveImdbRating(Services.SaveImdbRatingRequest request, ServerCallContext context)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!_validator.IsValidImdbRatingForSave(request, out var trailers))
            {
                throw NewInvalidArgumentRpcException("Invalid Imdb details", trailers);
            }

            var imdbRating = _mapper.Map <ImdbRating>(request.Imdb);

            var imdbRatingFromSave = await _movieDao
                                     .SaveImdbRating(request.MovieId, imdbRating)
                                     .ConfigureAwait(true);

            return(new Services.SaveImdbRatingResponse
            {
                Imdb = _mapper.Map <Services.Imdb>(imdbRatingFromSave)
            });
        }