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)); }
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("MovieID,MovieName,MovieDescription,GenreID")] MovieModel movieModel) { if (ModelState.IsValid) { _context.Add(movieModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenreID"] = new SelectList(_context.Genres, "GenreID", "GenreID", movieModel.GenreID); return(View(movieModel)); }
public async Task <IActionResult> ReturnMovie(int?id) { if (id == null) { return(NotFound()); } var rentalRecordModel = await _context.RentalRecords.SingleOrDefaultAsync(m => m.RentalID == id); if (rentalRecordModel == null) { return(NotFound()); } rentalRecordModel.ReturnDate = DateTime.Now; await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Return")); }