Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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()));
            }
        }
Esempio n. 3
0
        public override async Task <IEnumerable <GenreDto> > Handle(GetAllGenresQuery request, CancellationToken cancellationToken)
        {
            var genreEntities = await _data.Genres.GetAllAsync();

            return(_mapper.Map <IEnumerable <GenreDto> >(genreEntities));
        }
Esempio n. 4
0
 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());
        }