public ActionResult Create(Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ActorId = new SelectList(db.Actors, "Id", "Name", movie.ActorId); ViewBag.ActressId = new SelectList(db.Actresses, "Id", "Name", movie.ActressId); ViewBag.DirectorId = new SelectList(db.Directors, "Id", "Name", movie.DirectorId); ViewBag.StudioId = new SelectList(db.Studios, "Id", "Name", movie.StudioId); return View(movie); }
public void Init() { if (IsRunInSession) return; // Create movies m_Cinderella = new Movie("Cinderella", PriceCodes.Childrens); m_StarWars = new Movie("Star Wars", PriceCodes.Regular); m_Gladiator = new Movie("Gladiator", PriceCodes.NewRelease); m_BruceAlmighty = new Movie("Bruce Almighty", PriceCodes.NewRelease); // Create rentals m_Rental1 = new Rental(m_Cinderella, 5); m_Rental2 = new Rental(m_StarWars, 5); m_Rental3 = new Rental(m_Gladiator, 5); m_Rental4 = new Rental(m_BruceAlmighty, 365); // Create customers m_MickeyMouse = new Customer("Mickey Mouse"); m_DonaldDuck = new Customer("Donald Duck"); m_BillClinton = new Customer("Bill Clinton"); m_GeorgeBush = new Customer("George Bush"); IsRunInSession = true; }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ActorId = new SelectList(db.Actors, "Id", "Name", movie.ActorId); ViewBag.ActressId = new SelectList(db.Actresses, "Id", "Name", movie.ActressId); ViewBag.DirectorId = new SelectList(db.Directors, "Id", "Name", movie.DirectorId); ViewBag.StudioId = new SelectList(db.Studios, "Id", "Name", movie.StudioId); return View(movie); }