Example #1
0
 public ActionResult Create(Movie movie)
 {
     if (ModelState.IsValid)
     {
         var movieCreated = moviesService.CreateMovie(movie);
         return(Json(new { Success = movieCreated, Text = "Filme já cadastrado!" }));
     }
     ViewBag.GenreId = new SelectList(genresService.GetAllActives(), "Id", "NameGenre", movie.GenreId);
     return(View(movie));
 }
Example #2
0
        public void CreateMovieShouldAddMoviesToTheDatabase()
        {
            DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>()
                                                                 .UseInMemoryDatabase(databaseName: "Movies_CreateMovie_Database")
                                                                 .Options;
            UltimateMoviesDbContext db = new UltimateMoviesDbContext(options);

            IMoviesService moviesService = new MoviesService(db);

            moviesService.CreateMovie("Test 1", 10, 10, 10, "Description", "Directors", MovieGenre.Action,
                                      MovieGenre.Adventure, null, DateTime.Now, 100, 10, 100, "link", "Actor Name\r\nAnother Actor", "posterUrl",
                                      "trailerUrl");

            int moviesCount = db.Movies.ToList().Count();
            int actorsCount = db.Actors.ToList().Count();

            Assert.Equal(1, moviesCount);
            Assert.Equal(2, actorsCount);
        }