예제 #1
0
        public async Task <IActionResult> Create([Bind("MovieID,Category,Title,Year,Director,Rating,LentTo,Edited,Notes")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ViewMovies))); //after submitting redirects you back to the movie list
            }
            return(View(movie));                              //the movie object is added to the database
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Rating")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

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

                return(RedirectToAction(nameof(MovieList)));
            }
            return(View(movie));
        }