public ActionResult Edit([Bind(Include = "Id,FirstName,LastName")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "Id,Title,Genre,Duration")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
public ActionResult Edit([Bind(Include = "Id,CustomerId,MovieId,RentalDate,DueDate,ReturnDate")] Rental rental) { if (ModelState.IsValid) { db.Entry(rental).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerId = new SelectList(db.Customers, "Id", "FirstName", rental.CustomerId); ViewBag.MovieId = new SelectList(db.Movies, "Id", "Title", rental.MovieId); return(View(rental)); }
private void DeleteRental(VideoStoreContext videoStore, Rental rental) { ++rental.Movie.NumOfCopies; videoStore.Movies.Attach(rental.Movie); videoStore.Entry(rental.Movie).Property(m => m.NumOfCopies).IsModified = true; rental.User = null; rental.Movie = null; videoStore.Rentals.Attach(rental); videoStore.Rentals.Remove(rental); }
private void AddRental(VideoStoreContext videoStore, Rental rental) { var rentedMovie = new RentedMovie { MovieId = rental.MovieId, UserId = rental.UserId, }; --rental.Movie.NumOfCopies; videoStore.Movies.Attach(rental.Movie); videoStore.Entry(rental.Movie).Property(m => m.NumOfCopies).IsModified = true; rental.Movie = null; rental.User = null; videoStore.Rentals.Add(rental); videoStore.RentedMovies.Add(rentedMovie); }
public ActionResult SubmitReview(VideoReview model) { // either update or add new review entry to model, depending on whether it exists already. // a user can only have one review for a video. if (model.ReviewId == 0) { _db.VideoReview.Add(model); } else { _db.VideoReview.Attach(model); var entry = _db.Entry(model); entry.Property(i => i.Review).IsModified = true; entry.Property(i => i.Rating).IsModified = true; } _db.SaveChanges(); return(RedirectToAction("SingleVideo", "Home", new { inventoryId = model.InventoryId })); }