Exemple #1
0
        public ActionResult Edit(Movie movieToEdit)
        {
            var originalMovie = (from m in _db.MovieSet
                                 where m.Id == movieToEdit.Id
                                 select m).First();

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

            _db.ApplyPropertyChanges(originalMovie.EntityKey.EntitySetName, movieToEdit);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult Edit(int id, Movie item)
        {
            try
            {
                _db.Movies.FirstOrDefault(m => m.Id == item.Id);
                _db.ApplyPropertyChanges("MovieSet", item);
                _db.SaveChanges();

                return(RedirectToRoute(this.GetResourceRouteName(routeName, ActionType.Retrieve), new RouteValueDictionary {
                    { "id", item.Id }
                }));
            }
            catch (Exception exception)
            {
                throw new HttpException((int)HttpStatusCode.InternalServerError, "An error has occured; see details:", exception);
            }
        }