public async Task <IActionResult> SaveMovie([FromBody] MovieForSave movieForSave) { var saveRequest = new Services.SaveMovieRequest { Movie = _mapper.Map <Services.MovieForSave>(movieForSave) }; var saveResponse = await _movieService.SaveMovieAsync(saveRequest); var getRequest = new Services.GetMovieByIdRequest { MovieId = saveResponse.MovieId }; var getResponse = await _movieService.GetMovieByIdAsync(getRequest); var movie = _mapper.Map <Movie>(getResponse.Movie); return(CreatedAtAction( actionName: nameof(GetMovieById), routeValues: new { movieId = movie.Id }, value: movie)); }
public override async Task <Services.GetMovieByIdResponse> GetMovieById( Services.GetMovieByIdRequest request, ServerCallContext context) { if (request is null) { throw new ArgumentNullException(nameof(request)); } if (!_validator.IsValidGetMovieByIdRequest(request, out var trailers)) { throw NewInvalidArgumentRpcException("Invalid movie id", trailers); } var movie = await _movieDao .GetMovieById(request.MovieId) .ConfigureAwait(true); return(new Services.GetMovieByIdResponse { Movie = _mapper.Map <Services.Movie>(movie) }); }