Exemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            var movieToDelete = (from m in _entities.MovieSet
                                 where m.Id == id
                                 select m).FirstOrDefault();

            _entities.DeleteObject(movieToDelete);
            _entities.SaveChanges();
            return(PartialView("Movies", _entities.MovieSet.ToList()));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            try
            {
                Movie movie = _db.Movies.FirstOrDefault(m => m.Id == id);
                if (movie != null)
                {
                    // Delete should is idempotent, ignore if not present
                    _db.DeleteObject(movie);
                    _db.SaveChanges();
                }

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