public async Task <IActionResult> RecommendMovie([FromBody] RecommendMovieRequest request) { var response = await _mediator.Send(request); if (!response.HasError) { return(Ok(response)); } else { return(BadRequest(response)); } }
public async Task <BaseResponse <bool> > Handle(RecommendMovieRequest request, CancellationToken cancellationToken) { BaseResponse <bool> response = new BaseResponse <bool>(); try { var movie = await _movieRepository.Get(request.MovieId); var movieRecommendedIntegrationEvent = new MovieRecommendedIntegrationEvent(movie.Id, movie.Title, movie.Overview, movie.ReleaseDate, request.Email); await _eventBus.PublishAsync <MovieRecommendedIntegrationEvent>(typeof(MovieRecommendedIntegrationEvent).Name, movieRecommendedIntegrationEvent); response.Data = true; } catch (Exception ex) { response.Errors.Add(ex.Message); _logger.LogError("--- Publising Recomended Movie Error", "Movie Id:" + request.MovieId, "Message: " + ex.Message); } return(response); }