예제 #1
0
 public ActionResult Create(Movie newMovie)
 {
     if (ModelState.IsValid)
     {
         db.Movies.Add(newMovie);
         db.SaveChanges();
         return RedirectToAction(_Index);
     }
     else
     {
         return View(newMovie);
     }
 }
예제 #2
0
        public ActionResult Edit(Movie model)
        {
            try
            {
                var movie = db.Movies.Find(model.ID);

                UpdateModel(movie);
                db.SaveChanges();
                return RedirectToAction("Details", new { id = model.ID });
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Edit Failure, see inner exception");
            }

            return View(model);
        }