示例#1
0
        public async Task TestGetAllFilms_ReturnAllFilmsSuccessfully()
        {
            // Arrange
            int           page   = 1;
            string        search = null;
            FilmListModel model  = new FilmListModel()
            {
                Films = filmsList, TotalCount = filmsList.Count()
            };

            filmService.Setup(film => film.GetFilmsAsync(page, search)).ReturnsAsync(model);
            FilmsController controller = new FilmsController(filmService.Object, mapper);

            // Act
            var result = await controller.GetAllFilms();

            // Assert
            var okResult = result.Result as OkObjectResult;

            Assert.NotNull(okResult);

            var objectResult = okResult.Value as FilmListViewModel;

            Assert.NotNull(objectResult);
            Assert.Equal(filmsList.Count, objectResult.Films.Count());
            Assert.Equal(2006, objectResult.Films.FirstOrDefault().Year);

            filmService.Verify(f => f.GetFilmsAsync(page, search), Times.Once);
        }
        public async Task <ActionResult <FilmListViewModel> > GetAllFilms(int page = 1, string search = null)
        {
            FilmListViewModel filmList = new FilmListViewModel();
            FilmListModel     model    = await _filmService.GetFilmsAsync(page, search);

            filmList = _mapper.Map <FilmListModel, FilmListViewModel>(model);

            return(Ok(filmList));
        }
        public IActionResult Search(string q)
        {
            var filmViewModel = new FilmListModel()
            {
                //Categories=categories,
                Films = _filmService.GetSearchResult(q)
            };

            //ViewModel ile iki modeli birleştirip gönderdik
            return(View(filmViewModel));
        }
示例#4
0
        public async Task <FilmListModel> GetFilmsAsync(int page, string search)
        {
            IList <Film> films = await _filmRepository.GetFilmsAsync(page, pageSize, search);

            FilmListModel filmList = new FilmListModel()
            {
                Films      = _mapper.Map <IList <Film>, IList <FilmModel> >(films),
                TotalCount = await _filmRepository.GetTotalCountFilmsAsync(search)
            };

            return(filmList);
        }
示例#5
0
 private void FilmSelected(FilmListModel film) =>
 _mediator.Send(new SelectedMessage <FilmWrapper> {
     Id = film.Id
 });
示例#6
0
 private void DeleteActedInFilmSelected(FilmListModel film) => DeleteSelectActedInFilm(film.Id);
示例#7
0
 private void AddActedInFilmSelected(FilmListModel film) => AddSelectActedInFilm(film.Id);
 private void DeleteDirectedFilmSelected(FilmListModel film) => DeleteSelectDirectedFilm(film.Id);
 private void AddDirectedFilmSelected(FilmListModel film) => AddSelectDirectedFilm(film.Id);