Beispiel #1
0
        public override async Task <Services.SaveMovieResponse> SaveMovie(Services.SaveMovieRequest request, ServerCallContext context)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!_validator.IsValidMovieForSave(request, out var trailers))
            {
                throw NewInvalidArgumentRpcException("Invalid movie", trailers);
            }

            var movie = _mapper.Map <Movie>(request.Movie);

            var movieId = await _movieDao
                          .SaveMovie(movie)
                          .ConfigureAwait(true);

            return(new Services.SaveMovieResponse
            {
                MovieId = movieId.ToString()
            });
        }