Esempio n. 1
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)
            });
        }