Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created November 30, 2020 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/97b26e2f6e8357fc19132ea2aacbfb57 to your computer and use it in GitHub Desktop.
Save rahulsahay19/97b26e2f6e8357fc19132ea2aacbfb57 to your computer and use it in GitHub Desktop.
GetMoviesByDirectorNameHandler
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