示例#1
0
        public ActionResult Edit(int id, Movie updatedMovie)
        {
            try
            {
                var originalMovie = (from m in _db.Movies
                                     where m.Id == updatedMovie.Id
                                     select m).First();

                if (!ModelState.IsValid)
                {
                    return(View(originalMovie));
                }

                _db.ApplyCurrentValues(originalMovie.EntityKey.EntitySetName, updatedMovie);
                _db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }