public async Task <IActionResult> DeleteConfirmed(int movieId, int customerId, DateTime?loanDate) { Loan loan = await _context.Loan.FindAsync(movieId, customerId, loanDate); await _context.Entry(loan).Reference(l => l.Movie).LoadAsync(); await _context.Entry(loan).Reference(l => l.Customer).LoadAsync(); _context.Loan.Remove(loan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit([Bind(Include = "MembershipTypeId,Name,SignUpFee,DurationInMonths,DiscountRate")] MembershipType membershipType) { if (ModelState.IsValid) { db.Entry(membershipType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(membershipType)); }
public ActionResult Edit([Bind(Include = "Id,Nome,IsSubscribedToNewsletter,MembershipTypeId")] Cliente cliente) { if (ModelState.IsValid) { db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MembershipTypeId = new SelectList(db.MembershipTypes, "MembershipTypeId", "MembershipTypeId", cliente.MembershipTypeId); return(View(cliente)); }
public async Task <IActionResult> Edit([Bind("MovieId,Name,ReleaseDate,Producer,GenreId,Price")] Movie movieToEdit) { if (ModelState.IsValid) { if (_context.Movie.AsNoTracking().SingleOrDefault(x => x.MovieId == movieToEdit.MovieId) != null) { _context.Entry(movieToEdit).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } ViewBag.GenreId = new SelectList(_context.Genre, "GenreId", "Name", movieToEdit.GenreId); return(View(movieToEdit)); }