コード例 #1
0
        public async Task <IActionResult> Create([Bind("GenreID,GenreName")] GenresModel genresModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genresModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genresModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("CustomerID,CustomerName,CustomerEmail,CustomerPhoneNumber")] CustomersModel customersModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customersModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customersModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("MovieID,MovieTitle,YearReleased,Director,GenresModelID")] MoviesModel moviesModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(moviesModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenresModelID"] = new SelectList(_context.Genres, "GenreID", "GenreID", moviesModel.GenresModelID);
            return(View(moviesModel));
        }
コード例 #4
0
        public async Task <IActionResult> CheckInMovie(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var moviesModel = await _context.Movies
                              .Include(m => m.GenresModel)
                              .SingleOrDefaultAsync(m => m.MovieID == id);

            moviesModel.IsCheckedOut = false;
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Movies"));
        }