Ejemplo n.º 1
0
        public ActionResult RemoveMovie(string list_id, string movie_id)
        {
            MovieList movieList = _listContext.Find(list_id);

            if (movieList.AuthorID != _loggedInUserID)
            {
                return(RedirectToPage("~/Views/Shared/Error.cshtml"));
            }

            MovieListItem listItem = _listItemsContext.Collection().FirstOrDefault(i => (i.ListID == list_id && i.MovieID == movie_id));

            _listItemsContext.Delete(listItem.ID);
            _listItemsContext.Commit();

            movieList.DecrementSize();
            _listContext.Update(movieList);
            _listContext.Commit();

            return(RedirectToAction("View", new { list_id }));
        }