Created
November 30, 2020 15:15
-
-
Save rahulsahay19/97b26e2f6e8357fc19132ea2aacbfb57 to your computer and use it in GitHub Desktop.
GetMoviesByDirectorNameHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using MediatR; | |
using Movies.Application.Mappers; | |
using Movies.Application.Queries; | |
using Movies.Application.Responses; | |
using Movies.Core.Repositories; | |
namespace Movies.Application.Handlers | |
{ | |
public class GetMoviesByDirectorNameHandler : IRequestHandler<GetMoviesByDirectorNameQuery, IEnumerable<MovieResponse>> | |
{ | |
private readonly IMovieRepository _movieRepository; | |
public GetMoviesByDirectorNameHandler(IMovieRepository movieRepository) | |
{ | |
_movieRepository = movieRepository; | |
} | |
public async Task<IEnumerable<MovieResponse>> Handle(GetMoviesByDirectorNameQuery request, CancellationToken cancellationToken) | |
{ | |
var movieList = await _movieRepository.GetMoviesByDirectorName(request.DirectorName); | |
var movieResponseList = MovieMapper.Mapper.Map<IEnumerable<MovieResponse>>(movieList); | |
return movieResponseList; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment