public void GetAllMoviesShouldReturnIEnurableOfMovies() { DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>() .UseInMemoryDatabase(databaseName: "Movies_GetAllMovies_Database") .Options; UltimateMoviesDbContext db = new UltimateMoviesDbContext(options); IMoviesService moviesService = new MoviesService(db); db.Movies.Add(new Movie { Name = "Test 1" }); db.Movies.Add(new Movie { Name = "Test 2" }); db.Movies.Add(new Movie { Name = "Test 3" }); db.SaveChanges(); IEnumerable <Movie> movies = moviesService.GetAllMovies(); int moviesCount = movies.Count(); Assert.Equal(3, moviesCount); }
public IHttpActionResult GetMovies(string query = null) { IQueryable <Movie> moviesQuery = _movies.GetAllMovies(); if (!String.IsNullOrWhiteSpace(query)) { moviesQuery = moviesQuery.Where(c => c.Name.Contains(query)); } var movieDtos = moviesQuery.ToList().Select(Mapper.Map <Movie, MovieDto>); return(Ok(movieDtos)); }
public DataSet GetAllMovies() { MoviesService mov = new MoviesService(); return(mov.GetAllMovies()); }
public IActionResult GetMovies(string query = null) { var items = _movies.GetAllMovies(query); return(Ok(items)); }
public IActionResult GetAllMoviesJeson() { return(Json(service.GetAllMovies())); }