Example #1
0
        public async Task <IActionResult> Create([Bind("MovieId,Category,Title,YearReleased,DirectorName,MovieRating,IsEdited,IsLentTo,Notes")] AddMovie addMovie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(addMovie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(addMovie));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Rate rate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rate));
        }
        public async Task <IActionResult> Create([Bind("ActorId,FirtsName,LastName,Email")] Actor actor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(actor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(actor));
        }
Example #4
0
        public async Task <IActionResult> AddMovie([Bind("MovieId,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(MovieList)));
            }
            return(View("MovieList"));
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("MovieId,Category,Title,Year,Director,Rating,Edited,Lent_to,Notes")] MovieInfo movieInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Collection", movieInfo));
            }
            return(View());
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("DirectorId,DirectorFirstName,DirectorLastName")] Director director)
        {
            if (ModelState.IsValid)
            {
                _context.Add(director);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(director));
        }
Example #7
0
        public async Task <IActionResult> Create([Bind("MovieID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Example #8
0
        public async Task <IActionResult> Create([Bind("RatingId,MovieRatings,MovieId")] RatingModel ratingModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ratingModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieId"] = new SelectList(_context.MovieModels, "MovieId", "MovieName", ratingModel.MovieId);
            return(View(ratingModel));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Genre,Price,ReleaseDate,Rating")] Movie movie)
        {
            Log.Information("Added new Movie : " + movie.Title);
            if (ModelState.IsValid)  //arayüzdeki uyarıları ve attirubute lerin çalışmasını sağlayan kısım
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Example #10
0
        public async Task <IActionResult> Create([Bind("movieID,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] movie movie)
        {
            //onsubmit of added movie
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Example #11
0
        public async Task <IActionResult> Create([Bind("Id,Title,Genre,Runtime")] Movies movies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag["Error"] = "An error has occurred in the program";
            return(View("Index", ViewBag));
        }
        public async Task <IActionResult> Create([Bind("MovieId,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] ApplicationResponse applicationResponse)
        {
            if (ModelState.IsValid)
            {
                Context.Add(applicationResponse);
                //When  in an async method use the savechangesAsync
                await Context.SaveChangesAsync();

                //Takes us back to the index page
                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationResponse));
        }
Example #13
0
        public async Task <IActionResult> Create([Bind("MovieId,MovieTitle,MovieYear,MovieLanguage,MoviePath,MovieCoverImage")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Example #14
0
 public bool Create(Director director)
 {
     try
     {
         _movieDbContext.Add(director);
         _movieDbContext.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
        [HttpPost]//httppost response for NewMovie view
        public IActionResult NewMovie(Movie movie)
        {
            //checks model to make sure its valid
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                _context.SaveChanges();
                return(RedirectToAction("Confirmation", movie));
            }


            return(View());
        }
Example #16
0
        public async Task <IActionResult> Create([Bind("MovieId,GenreId")] MovieGenre movieGenre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieGenre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenreId"] = new SelectList(_context.Genres, "GenreId", "GenreId", movieGenre.GenreId);
            ViewData["MovieId"] = new SelectList(_context.Movies, "MovieId", "MovieId", movieGenre.MovieId);
            return(View(movieGenre));
        }
Example #17
0
        public async Task <IActionResult> Create([Bind("Id,Title,Year,Description,GenreId,AuthorId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Firstname", movie.AuthorId);
            ViewData["GenreId"]  = new SelectList(_context.Genres, "Id", "Name", movie.GenreId);
            return(View(movie));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Released,RunTime,Plot,FormatId,RateId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FormatId"] = new SelectList(_context.Format, "Id", "Name", movie.FormatId);
            ViewData["RateId"]   = new SelectList(_context.Rate, "Id", "Name", movie.RateId);
            return(View(movie));
        }
Example #19
0
        public async Task <IActionResult> Create([Bind("DirectorId,MovieId")] MovieDirection movieDirection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieDirection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DirectorId"] = new SelectList(_context.Directors, "DirectorId", "DirectorId", movieDirection.DirectorId);
            ViewData["MovieId"]    = new SelectList(_context.Movies, "MovieId", "MovieId", movieDirection.MovieId);
            return(View(movieDirection));
        }
Example #20
0
        public async Task <Actor> CreateActorAsync(string name, DateTime born)
        {
            var actor = new Actor()
            {
                Name = name,
                Born = born
            };

            _dbContext.Add(actor);

            await _dbContext.SaveChangesAsync();

            return(actor);
        }
        public async Task <int> PostMovie(CreateMovieServiceModel movieServiceModel)
        {
            var movie = new Data.Models.Movie
            {
                DirectorName = movieServiceModel.DirectorName,
                Genre        = movieServiceModel.Genre,
                Name         = movieServiceModel.Name,
                ReleaseYear  = movieServiceModel.ReleaseYear
            };

            _dbContext.Add(movie);
            await _dbContext.SaveChangesAsync();

            return(movie.Id);
        }
        public async Task <IActionResult> AddMovie([Bind("MovieID,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] Movie movie)
        {
            if (ModelState.IsValid && movie.Title == "Independence Day")
            {
                return(View("Confirmation", movie));
            }
            if (ModelState.IsValid && movie.Title != "Independence Day")
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(View("Confirmation", movie));
            }
            return(View(movie));
        }
Example #23
0
        public async Task <Director> CreateDirectorAsync(string name, int age, string country)
        {
            var director = new Director()
            {
                Name    = name,
                Age     = age,
                Country = country
            };

            _dbContext.Add(director);

            await _dbContext.SaveChangesAsync();

            return(director);
        }
Example #24
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,Year,Producer,NewPoster")] MovieViewModel movieVM)
        {
            if (ModelState.IsValid)
            {
                var movie         = _mapper.Map <MovieModel>(movieVM);
                var currentUserId = _userManager.GetUserId(User);
                movie.AuthorId = currentUserId;

                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movieVM));
        }
        public int AddMovieActorMap(Movie movie, Actor actor)
        {
            if (movie == null)
            {
                throw new Exception("Movie is null");
            }

            if (actor == null)
            {
                throw new Exception("Actor is null");
            }

            var movieActorMapping = new MovieActorMapping
            {
                Movie = movie,
                Actor = actor
            };

            _context.Add(movieActorMapping);

            var records = _context.SaveChanges();

            return(records);
        }
Example #26
0
        public async Task <Movie> CreateMovieAsync(string title, DateTime releaseDate, string director, string genre)
        {
            var movie = new Movie()
            {
                Title       = title,
                ReleaseDate = releaseDate,
                Genre       = genre,
                Director    = director
            };

            _dbContext.Add(movie);

            await _dbContext.SaveChangesAsync();

            return(movie);
        }
Example #27
0
        private static void AddAMovie(MovieDbContext dbContext)
        {
            // because DbSet is IQueryable...
            // this LINQ expression does not ever actually run as C#,
            // it is translated to a SQL query. "LINQ To SQL"
            // e.g. in SQL string compare is case-insensitive:
            var actionGenre = dbContext.Genre.First(g => g.Name == "acTIOn");

            var movie = new Movie
            {
                Title       = "Star Wars VIII",
                ReleaseDate = new DateTime(2018, 1, 1),
                Genre       = actionGenre
            };

            // i am ultimately setting up a foreign key relationship
            // but i'm doing it by setting navigation properties

            dbContext.Add(movie);

            // this would also work... but i don't need to do both!
            //actionGenre.Movie.Add(movie);

            // nothing has yet been sent to the real DB...

            try
            {
                dbContext.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                dbContext.Movie.Remove(movie);
                Console.WriteLine(ex.Message);
            }

            // now the new movie is in the real DB.
        }
Example #28
0
 public async Task Create(Movie movie)
 {
     _context.Add(movie);
     await _context.SaveChangesAsync();
 }
Example #29
0
        public async Task <IActionResult> Create(MovieViewModel movieModel)
        {
            if (ModelState.IsValid)
            {
                var movie = new Movie()
                {
                    Title        = movieModel.Title,
                    Description  = movieModel.Description,
                    MovieLenght  = movieModel.MovieLenght,
                    Rating       = movieModel.Rating,
                    DateReleased = movieModel.DateReleased,
                    PosterPath   = movieModel.PosterPath
                };
                _context.Add(movie);
                _context.SaveChanges();

                var getMovie      = _context.Movies.Find(movie.MovieID);
                var listOfPersons = new List <MoviePersons>();
                listOfPersons.Add(new MoviePersons()
                {
                    MovieID      = getMovie.MovieID,
                    PersonID     = movieModel.SelectedDirector,
                    PersonRoleID = 1
                });
                listOfPersons.Add(new MoviePersons()
                {
                    MovieID      = getMovie.MovieID,
                    PersonID     = movieModel.SelectedScreenplay,
                    PersonRoleID = 3
                });
                foreach (var actorID in movieModel.SelectedActors)
                {
                    listOfPersons.Add(new MoviePersons()
                    {
                        MovieID      = getMovie.MovieID,
                        PersonID     = Convert.ToInt32(actorID),
                        PersonRoleID = 2
                    });
                }
                foreach (var item in listOfPersons)
                {
                    _context.Add(item);
                }


                var listOfGenres = new List <MovieGenres>();
                foreach (var genreId in movieModel.SelectedGenres)
                {
                    listOfGenres.Add(new MovieGenres
                    {
                        MovieID = getMovie.MovieID,
                        GenreID = Convert.ToInt32(genreId)
                    });
                }

                foreach (var item in listOfGenres)
                {
                    _context.Add(item);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movieModel));
        }
 public void AddMovie(Movie movie)
 {
     _context.Add(movie);
 }