public async Task <IActionResult> Edit(int id, [Bind("RentalID,MovieID,CustomerID,RentalDate,DueDate,ReturnDate")] RentalRecordModel rentalRecordModel)
        {
            if (id != rentalRecordModel.RentalID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rentalRecordModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RentalRecordModelExists(rentalRecordModel.RentalID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID", rentalRecordModel.CustomerID);
            ViewData["MovieID"]    = new SelectList(_context.Movies, "MovieID", "MovieID", rentalRecordModel.MovieID);
            return(View(rentalRecordModel));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("MovieID,MovieName,MovieDescription,GenreID")] MovieModel movieModel)
        {
            if (id != movieModel.MovieID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieModelExists(movieModel.MovieID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenreID"] = new SelectList(_context.Genres, "GenreID", "GenreID", movieModel.GenreID);
            return(View(movieModel));
        }
Пример #3
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));
        }