public async Task GetAllGenresTest() { var genresReturns = _genreFaker.GenerateForever().Take(10).ToList(); _dbContext.GetGenres().Returns(genresReturns); var getAllGenresQueryHandler = new GetAllGenresQueryHandler(_dbContext); var getAllGenresQuery = new GetAllGenresQuery(); var genres = await getAllGenresQueryHandler.Handle(getAllGenresQuery, CancellationToken.None); genres.Should().Equal(genresReturns); }
public async Task <IActionResult> GetAll() { var getAllGenresQuery = new GetAllGenresQuery(); try { var genres = await _mediator.Send(getAllGenresQuery); var response = _mapper.Map <IList <Genre>, IList <GetGenreResponse> >(genres); return(Ok(response)); } catch (Exception e) { return(BadRequest(e.ToString())); } }
public override async Task <IEnumerable <GenreDto> > Handle(GetAllGenresQuery request, CancellationToken cancellationToken) { var genreEntities = await _data.Genres.GetAllAsync(); return(_mapper.Map <IEnumerable <GenreDto> >(genreEntities)); }
public GenresController() { _createGenreCommand = new CreateGenreCommand(); _getAllGenresQuery = new GetAllGenresQuery(); }
public async Task <IList <Genre> > Handle(GetAllGenresQuery request, CancellationToken cancellationToken) { await _dbContext.GetDb(); return(await _dbContext.GetGenres()); }