public async Task <Principal> Delete(int id) { var principal = await db.Principals.FindAsync(id); if (principal == null) { return(null); } else { try { logger.LogInformation($"[{nameof(Delete)}] - Deleting Principal #{id}, {principal.Name}"); db.Remove(principal); await db.SaveChangesAsync(); return(principal); } catch (PostgresException pe) { logger.LogError($"[!!!{nameof(Delete)}!!!] {pe.Message}"); return(null); } } }
public IActionResult DeleteTheatre(TheatreModel mytheatre) { _dbContext.Remove(mytheatre).State = EntityState.Deleted; _dbContext.SaveChanges(); return(View()); }
public IActionResult DeleteLocation(LocationModel mylocation) { _dbContext.Remove(mylocation).State = EntityState.Deleted; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult DeleteRating(RatingModel ratingmodel) { _Dbcontext.Remove(ratingmodel).State = EntityState.Deleted; //ViewData["MovieId"] = new SelectList(_Dbcontext.MovieModels, "MovieId", "MovieName"); _Dbcontext.SaveChanges(); return(RedirectToAction("index")); }
public MovieList DeleteListById(int movieListId) { var ml = _context.MovieLists.First(l => l.Id == movieListId); _context.Remove(ml); _context.SaveChanges(); return(ml); }
public Movie Delete(int Id) { Movie movie = _context.Movie.Find(Id); if (movie != null) { _context.Remove(movie); _context.SaveChanges(); } return(movie); }
private static void DeleteAMovie(MovieDbContext dbContext) { // the most recently modified movie, with LINQ Movie movie = dbContext.Movie .OrderByDescending(m => m.DateModified) .First(); dbContext.Remove(movie); // this will use the SQL-defined "on delete cascade" behavior if present. // (if there are any foreign keys pointing at the thing we are removing.) dbContext.SaveChanges(); }
public bool DeleteById(int id) { var actor = _movieDbContext.Actors.Include(i => i.Movies).FirstOrDefault(i => i.Id == id); try { _movieDbContext.Remove(actor); _movieDbContext.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public bool DeleteById(int id) { var query = _movieDbContext.Directors.FirstOrDefault(i => i.Id == id); try { _movieDbContext.Remove(query); _movieDbContext.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public async Task <bool> DeleteMovieAsync(int id) { var movie = await _dbContext.Movies.FindAsync(id); if (movie is null) { return(false); throw new ArgumentException("Movie does not exist"); } _dbContext.Remove(movie); await _dbContext.SaveChangesAsync(); return(true); }
public async Task <bool> DeleteActorAsync(int id) { var actor = await _dbContext.Actors.FindAsync(id); if (actor is null) { return(false); throw new ArgumentException("Actor does not exist"); } _dbContext.Remove(actor); await _dbContext.SaveChangesAsync(); return(true); }
public IActionResult MovieList(int movieId, string actionType) { if (actionType == "Edit") { //if user wants to edit a movie, pass that movie information to the EditMovie var EditMovie = _context.Movies.Where(m => m.MovieId == movieId).FirstOrDefault(); return(View("EditMovie", EditMovie)); } else if (actionType == "Delete") { //if user wants to delete a movie, remove it from context by MovieId _context.Remove(_context.Movies.Where(m => m.MovieId == movieId).FirstOrDefault()); _context.SaveChanges(); return(View("DeleteConfirmation")); } else { return(View()); } }
public IActionResult DeleteTheater(TheaterModel theatermodel) { _Dbcontext.Remove(theatermodel).State = EntityState.Deleted; _Dbcontext.SaveChanges(); return(RedirectToAction("index")); }
public IActionResult DeleteMovies(int id) { _context.Remove(_context.AddMovie.Single(x => x.MovieID == id)); _context.SaveChanges(); return(RedirectToAction("Database")); }
public IActionResult DeleteRating(RatingModel myrating) { _dbContext.Remove(myrating).State = EntityState.Deleted; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult DeleteMovie(MovieModel movie) { _DbContext.Remove(movie).State = EntityState.Deleted; _DbContext.SaveChanges(); return(RedirectToAction("index")); }
//delete functionality public IActionResult DeleteMovie(int id) { _context.Remove(_context.Movies.Single(x => x.MovieId == id)); _context.SaveChanges(); return(RedirectToAction("MovieList")); }
public IActionResult DeleteLocation(LocationModel locationmodel) { _DbContext.Remove(locationmodel).State = EntityState.Deleted; _DbContext.SaveChanges(); return(RedirectToAction("index")); }