Esempio n. 1
0
        public async Task <IActionResult> SaveTomatoesRating([FromRoute] string movieId, [FromBody] TomatoesForSave tomatoesForSave)
        {
            var request = new Services.SaveTomatoesRatingRequest
            {
                Tomatoes = _mapper.Map <Services.Tomatoes>(tomatoesForSave),
                MovieId  = movieId
            };

            await _movieService.SaveTomatoesRatingAsync(request);

            return(NoContent());
        }
Esempio n. 2
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)
            });
        }