Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerID,CustomerName,CustomerPhoneNumber")] CustomerModel customerModel)
        {
            if (id != customerModel.CustomerID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerModelExists(customerModel.CustomerID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerModel));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreID,GenreName")] GenreModel genreModel)
        {
            if (id != genreModel.GenreID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genreModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreModelExists(genreModel.GenreID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genreModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("MovieID,CustomerID,RentalDate,DueDate,ReturnDate")] RentalRecordModel RentalRecordViewModel)
        {
            if (id != RentalRecordViewModel.RentalID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(RentalRecordViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RentalRecordViewModelExists(RentalRecordViewModel.RentalID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customer, "CustomerID", "CustomerID", RentalRecordViewModel.CustomerID);
            ViewData["MovieID"]    = new SelectList(_context.Movie, "MovieID", "MovieID", RentalRecordViewModel.MovieID);
            return(View(RentalRecordViewModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("MovieID,MovieName,MovieDescription,GenreID")] MovieModel MovieViewModel)
        {
            if (id != MovieViewModel.MovieID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(MovieViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieViewModelExists(MovieViewModel.MovieID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(MovieViewModel));
        }