public async Task <IActionResult> Edit(int id, [Bind("Id,RentalID,MovieID,CustomerID,RentalDate,DueDate,ReturnDate")] RentalRecordModel rentalRecordModel) { if (id != rentalRecordModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rentalRecordModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentalRecordModelExists(rentalRecordModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rentalRecordModel)); }
public async Task <IActionResult> CheckIn(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 StoreViewModel(RentalRecordModel rentalRecord) { this.DueDate = rentalRecord.DueDate; this.RentalDate = rentalRecord.RentalDate; this.DueDate = rentalRecord.DueDate; this.RentalDate = rentalRecord.RentalDate; }
public async Task <IActionResult> Create([Bind("Id,RentalID,MovieID,CustomerID,RentalDate,DueDate,ReturnDate")] RentalRecordModel rentalRecordModel) { if (ModelState.IsValid) { _context.Add(rentalRecordModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(rentalRecordModel)); }
public IActionResult CreateRecord(int movie, int customer, DateTime rentaldate, DateTime duedate) { var newRecord = new RentalRecordModel { MovieID = movie, CustomerID = customer, RentalDate = rentaldate, DueDate = duedate }; _context.RentalRecords.Add(newRecord); _context.SaveChanges(); return(Redirect("Index")); }
public RentalRecordModel CheckInMovie(RentalRecordModel rentedMovie) { rentedMovie.ReturnDate = DateTime.Now; return(rentedMovie); }