Example #1
0
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }
Example #2
0
 public ActionResult Edit(Movie movie)
 {
     //ModelState.AddModelError("", "xx");
     if (ModelState.IsValid)
     {
         movie = db.Movies.Find(movie.ID);
         UpdateModel(movie, new string[] { "Title" });
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(movie);
 }