public void GetAllMoviesWithTitleMatchingSearchTextTest()
        {
            //Arrange
            var seedDB = new List <MovieModelDAL>();
            var seed   = new MovieModelDAL
            {
                ID         = 5050,
                Title      = "Movie",
                Year       = 2018,
                Rated      = "10",
                Runtime    = "20 min",
                Genre      = "Commedy",
                Director   = "Director",
                Plot       = "Some Plot",
                Poster     = "www.poster.com",
                ImdbRating = 10f,
                ScreenShot = "www.screenshot.com"
            };

            seedDB.Add(seed);
            var controller = new MoviesLogic(new MovieDALStub(seedDB));
            var rightInput = "Movie";
            var wrongInput = "Not";
            //Act
            var result1 = controller.GetAllMoviesWithTitleMatchingSearchText(rightInput);
            var result2 = controller.GetAllMoviesWithTitleMatchingSearchText(wrongInput);

            //Assert
            Assert.IsTrue(result1.Count == 1);
            Assert.IsFalse(result2.Count > 0);
        }
 public string GetMovieData(string searchQuery)
 {
     if (searchQuery == null || searchQuery == "")
     {
         var json = "[]";
         return(json);
     }
     else
     {
         var movie = _moviesLogic.GetAllMoviesWithTitleMatchingSearchText(searchQuery);
         var json  = new JavaScriptSerializer().Serialize(movie).ToString();
         return(json);
     }
 }
Beispiel #3
0
        public ActionResult Search(string searchText)
        {
            if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false))
            {
                return(RedirectToRoute(new
                {
                    controller = "Home",
                    action = "Index"
                }));
            }

            var movies       = _moviesLogic.GetAllMoviesWithTitleMatchingSearchText(searchText);
            var mappedMovies = ModelMapper.MapFromListOfMovieBllModelToListOfMovieViewModelList(movies);

            var moviesListWrapperObject = new MoviesListWrapperViewModel()
            {
                Movies     = mappedMovies,
                SearchText = ""
            };

            return(View("Index", moviesListWrapperObject));
        }