Example #1
0
        public override async Task <Services.SaveTomatoesRatingResponse> SaveTomatoesRating(Services.SaveTomatoesRatingRequest request, ServerCallContext context)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

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

            var tomatoesRating = _mapper.Map <TomatoesRating>(request.Tomatoes);

            var tomatoesRatingFromSave = await _movieDao
                                         .SaveTomatoesRating(request.MovieId, tomatoesRating)
                                         .ConfigureAwait(true);

            return(new Services.SaveTomatoesRatingResponse
            {
                Tomatoes = _mapper.Map <Services.Tomatoes>(tomatoesRatingFromSave)
            });
        }