public ActionResult Create([Bind(Include = "MovieID,Title,Director,Genre")] Movy movy)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movy));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Phone")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "RentalID,CustomerID,MovieID,DateRented")] Rental rental)
        {
            if (ModelState.IsValid)
            {
                db.Rentals.Add(rental);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", rental.CustomerID);
            ViewBag.MovieID    = new SelectList(db.Movies, "MovieID", "Title", rental.MovieID);
            return(View(rental));
        }