public IActionResult AddMovies() { AddMovieModel movieModel = new AddMovieModel(); AddMovieViewModel pageData = movieModel.GetData(); return(View(pageData)); }
public IActionResult Delete(int id = 0) { //finding the movieId and deleting it and saving the database AddMovieModel _movie = context.Movies.Find(id); context.Movies.Remove(_movie); context.SaveChanges(); return(RedirectToAction("ShowMovies")); }
public IActionResult Edit(AddMovieModel movie) { if (ModelState.IsValid) { context.Movies.Update(movie); context.SaveChanges(); Response.Redirect("MoviesList"); } return(View()); }
public IActionResult Edit(AddMovieModel _mov) { if (ModelState.IsValid) { //modifying the entry and saving the changes context.Entry(_mov).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("ShowMovies")); } return(View(_mov)); }
public IActionResult Edit(int id = 0) { //finding the movieId then autopopulating the edit page with that movie's info AddMovieModel _mov = context.Movies.Find(id); if (_mov == null) { //return HttpNotFound(); } return(View(_mov)); }
public IActionResult AddMovie(AddMovieModel m) { if (ModelState.IsValid) { //update database context.Movies.Add(m); context.SaveChanges(); return(RedirectToAction("ShowMovies")); } return(View(m)); }
public async Task <ActionResult <MovieDetailsModel> > Add([FromBody] AddMovieModel model, CancellationToken cancellationToken) { var command = new AddMovieCommand(model.Id.Value); var result = await Dispatcher.DispatchAsync(command, cancellationToken); if (result is null) { return(NotFound()); } var url = Url.Action(nameof(GetById), new { id = result.Id }); return(Created(url, result)); }