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> CheckIn(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", "Home")); }