public IActionResult ConfirmDelete(string id) { ObjectId movieId = new ObjectId(id); MovieRepository.DeleteMovie(movieId); return(Redirect("/Movie")); }
public IActionResult DeleteMovie(int movieId) { var repo = new MovieRepository(); repo.DeleteMovie(movieId); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["sort"] == "rating_desc") { Repeater1.DataSource = MovieRepository.GetAllMoviesByDescRating(); Repeater1.DataBind(); } else if (Request.QueryString["sort"] == "year_desc") { Repeater1.DataSource = MovieRepository.GetAllMoviesByDescYear(); Repeater1.DataBind(); } else { Repeater1.DataSource = MovieRepository.GetAllMovies(); Repeater1.DataBind(); } //For Delete if (Request.QueryString["ID"] != null) { int id = int.Parse(Request.QueryString["ID"]); MovieRepository.DeleteMovie(id); Response.Redirect("ListOfMovies.aspx"); } }
}//GetAllFilename /// <summary> /// Delete movies from the database if they are no longer in the folder /// </summary> /// <param name="filePaths">Name of the file that have just been scanned</param> /// <param name="ogFileNamePath">Path to the file with that containes the file names of the previous scan</param> private void DeleteMovies(List <string> filePaths, string ogFileNamePath) { List <string> originalFileNames = new List <string>(File.ReadAllLines(ogFileNamePath)); List <string> fileNames = new List <string>(); foreach (string filePath in filePaths) { fileNames.Add(Path.GetFileName(filePath)); } foreach (string originalFileName in originalFileNames) { bool inFile = false; foreach (string fileName in fileNames) { if (originalFileName == fileName) { inFile = true; } } if (!inFile) { MovieRepository movieRepo = new MovieRepository(); int idMovie = movieRepo.MovieExists("filename", originalFileName); movieRepo.DeleteMovie(idMovie); } } File.WriteAllLines(ogFileNamePath, fileNames); }
public IActionResult DeleteEvent(int eventId) { var eventToDelete = _eventRepository.GetEventByEventId(eventId); _inviteRepository.DeleteInvite(eventId); _eventRepository.DeleteEvent(eventId); _movieRepository.DeleteMovie(eventToDelete.MovieId); return(Ok(eventToDelete)); }
/// <summary> /// the user gets to select a movie by index and delete it /// </summary> public static void DeleteMovie() { Movie movie = CommonClasses.SelectMovieById.SelectMovie("delete"); if (movie != null) { MovieRepository.DeleteMovie(movie.Id); StandardMessages.DeletedMessage("movie"); } }
//[Authorize(Roles = "Admin Role2")] //UND-Verknüpfung -> User in beiden Rollen //[Authorize(Roles = "Admin, Role2")] //ODER-Verknüpfung -> User einer der beiden Rollen public async Task <IHttpActionResult> Delete(int id) { Movie movie = await _movie.GetMovie(id); if (movie == null) { return(NotFound()); } await _movie.DeleteMovie(movie); return(Ok()); }
public ActionResult DeleteMovie(int id) { var movieModel = _repo.GetMovieById(id); if (movieModel == null) { return(NotFound()); } _repo.DeleteMovie(movieModel); _repo.SaveChanges(); return(NoContent()); }
private async Task DeleteMovie(Movie movie) { await Js.MyFunction("Requested Movie delete"); var result = await Js.Confirm($"Are you sure you want to delete {movie.Title}?"); if (result) { await MovieRepository.DeleteMovie(movie.Id); Movies.Remove(movie); } }
public ActionResult DeleteConfirmed(int id) { try { Models.MovieModel movie = _movieRepository.GetMovieByID(id); _movieRepository.DeleteMovie(id); _movieRepository.Save(); } catch (DataException) { return(RedirectToAction("Delete", new System.Web.Routing.RouteValueDictionary { { "id", id }, { "saveChangesError", true } })); } return(RedirectToAction("Index")); }
public void Log_When_Movie_Is_Deleted_And_Send_An_Email() { var contextMock = new Mock <MovieContext>(); var logMock = new Mock <ILog>(); var mailerMock = new Mock <IMailer>(); var repository = new MovieRepository(contextMock.Object, logMock.Object, mailerMock.Object); var movieToDelete = new Movie() { Id = 1, Name = "Star Wars" }; logMock.Setup(x => x.InfoFormat("Movie with id {0} and name {1} was deleted!", 1, "Star Wars")); contextMock.Setup(x => x.Movies.Find(1)).Returns(movieToDelete); contextMock.Setup(x => x.Movies.Remove(movieToDelete)); contextMock.Setup(x => x.SaveChanges()); mailerMock.Setup(x => x.SendEmail("*****@*****.**", "*****@*****.**", "Movie with name Star Wars was deleted!")); repository.DeleteMovie(1); logMock.VerifyAll(); contextMock.VerifyAll(); }
public void DeleteMovie(Guid id) { _repo.DeleteMovie(id); }
public void DeleteMovie(Guid movieId) { _movieRepo.DeleteMovie(movieId); }
public void DeleteMovie(int id) { movieRepository.DeleteMovie(id); }