private void btnDelete_Click(object sender, EventArgs e) { var mr = new MoviesRepository(); int movieId = Convert.ToInt32(txtMovieId.Text); mr.DeleteMovie(movieId); MessageBox.Show("Movie deleted successfully!", "Movie deleted"); txtMovieId.Clear(); }
// GET: Movies/Delete/5 public ActionResult Delete(int id) { List <Movies> movies = moviesRepository.ListMovie(); Movies movie = (from m in movies where m.Id == id select m).Single(); moviesRepository.DeleteMovie(movie); return(RedirectToAction("List")); }
public ActionResult DeleteConfirmed(int id) { Movie movie = moviesRepository.GetMovieById(id); if (!string.IsNullOrEmpty(movie.PosterFilePath) && movie.PosterFilePath != "~/Images/no-image.png") { string fullPath = Request.MapPath(movie.PosterFilePath); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } TempData["Notification"] = movie.Name + " has been deleted from the movies database!"; moviesRepository.DeleteMovie(id); return(RedirectToAction("Index")); }