Exemplo n.º 1
0
        public IActionResult Add(AddStreamingServiceViewModel addStreamingServiceViewModel)
        {
            if (ModelState.IsValid)
            {
                MovieStreamingService newStreamingService = new MovieStreamingService
                {
                    StreamingService = addStreamingServiceViewModel.Name
                };

                context.StreamingServices.Add(newStreamingService);
                context.SaveChanges();

                return(Redirect("/Movie/Add"));
            }

            return(View(addStreamingServiceViewModel));
        }
Exemplo n.º 2
0
        public IActionResult Add(AddMovieViewModel addMovieViewModel)
        {
            if (ModelState.IsValid)
            {
                MovieGenre            newMovieGenre            = context.Genres.SingleOrDefault(c => c.ID == addMovieViewModel.GenreID);
                MovieStreamingService newMovieStreamingService = context.StreamingServices.SingleOrDefault(c => c.ID == addMovieViewModel.StreamingServiceID);


                Movie newMovie = new Movie
                {
                    Title            = addMovieViewModel.Name,
                    StreamingService = newMovieStreamingService,
                    Genre            = newMovieGenre
                };

                context.Movies.Add(newMovie);
                context.SaveChanges();

                return(Redirect("/Movie"));
            }

            return(View(addMovieViewModel));
        }