Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ProducerID,Name")] Producer producer)
        {
            if (ModelState.IsValid)
            {
                db.Producers.Add(producer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(producer));
        }
        public ActionResult Create([Bind(Include = "StarID,Name")] Star star)
        {
            if (ModelState.IsValid)
            {
                db.Stars.Add(star);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(star));
        }
 public ActionResult Create([Bind(Include = "Title,ReleaseDate,Star,Producer")] Movie movie)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Movies.Add(movie);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(movie));
 }