public IActionResult GetMovie(int id) { if (!_movieDatabaseRepository.MovieExists(id)) { return(NotFound()); } var movie = _movieDatabaseRepository.GetMovie(id); if (movie == null) { return(NotFound()); } var movieResult = Mapper.Map <MovieDto>(movie); return(Ok(movieResult)); }
public async Task <MovieDto> Handle(GetMovieForDirectorQuery request, CancellationToken cancellationToken) { if (!_movieDatabaseRepository.DirectorExists(request.DirectorId)) { return(null); } var movieForDirectorFromRepo = await _movieDatabaseRepository.GetMovie(request.DirectorId, request.MovieId); if (movieForDirectorFromRepo == null) { return(null); } return(_mapper.Map <MovieDto>(movieForDirectorFromRepo)); }
public async Task <bool> Handle(UpdateMovieForDirectorCommand request, CancellationToken cancellationToken) { if (!_movieDatabaseRepository.DirectorExists(request.DirectorId)) { return(false); } var movieForDirectorFromRepo = await _movieDatabaseRepository.GetMovie(request.DirectorId, request.MovieId); if (movieForDirectorFromRepo == null) { return(false); } _mapper.Map(request.Movie, movieForDirectorFromRepo); _movieDatabaseRepository.UpdateMovie(movieForDirectorFromRepo); _movieDatabaseRepository.Save(); return(true); }