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> Create([Bind("CustomerID,CustomerName,CustomerPhoneNumber")] CustomerModel customerModel) { if (ModelState.IsValid) { _context.Add(customerModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customerModel)); }
public async Task <IActionResult> Create([Bind("GenreID,GenreName")] GenreModel genreModel) { if (ModelState.IsValid) { _context.Add(genreModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(genreModel)); }
public async Task <IActionResult> Create([Bind("MovieID,MovieName,MovieDescription,GenreID")] MovieModel MovieModel) { if (ModelState.IsValid) { _context.Add(MovieModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(MovieModel)); }
// GET: Return/CheckIn/5 public async Task <IActionResult> CheckIn(int?id) { if (id == null) { return(NotFound()); } var rentalRecordModel = await _context.RentalRecord.SingleOrDefaultAsync(m => m.RentalID == id); if (rentalRecordModel == null) { return(NotFound()); } rentalRecordModel.ReturnDate = DateTime.Now; await _context.SaveChangesAsync(); return(RedirectToAction("Index", "RentalRecord")); }