public IActionResult Edit(int id, [Bind("Title,ReleaseDate,Genre,Price")] EditMovieViewModel editModel) { if (ModelState.IsValid) { try { var movie = _mapper.Map <Movie>(editModel); { movie.Id = id; _context.Update(movie); _context.SaveChanges(); }; _context.Update(movie); _context.SaveChanges(); } catch (DbUpdateException) { if (!MovieExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(editModel)); }
public async Task <IActionResult> Edit(int id, [Bind("EnquiryId,Email,Message")] Enquiry enquiry) { if (id != enquiry.EnquiryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enquiry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnquiryExists(enquiry.EnquiryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(enquiry)); }
public async Task <IActionResult> Edit(int id, [Bind("MovieComingSoonId,ImageUrl,LongDescription,ShortDescription,Title")] MovieComingSoon movieComingSoon) { if (id != movieComingSoon.MovieComingSoonId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movieComingSoon); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieComingSoonExists(movieComingSoon.MovieComingSoonId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(movieComingSoon)); }
public async Task <IActionResult> Edit(int id, [Bind("MovieID,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] Movies movies) { if (id != movies.MovieID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MoviesExists(movies.MovieID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(EnteredList))); } return(View(movies)); }
public Movie UpdateData(Movie movie) { _context.Update(movie); _context.SaveChanges(); return(movie); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ReleaseDate,Director,Email,Language,Category")] MovieTble movieTble) { if (id != movieTble.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movieTble); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieTbleExists(movieTble.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Category"] = new SelectList(_context.CategoryTble, "Code", "Code", movieTble.Category); return(View(movieTble)); }
public IActionResult Edit(int id, [Bind("Name,FirstName,DateOfBirth")] EditActorViewModel editModel) { if (ModelState.IsValid) { try { var actor = new Actor { Id = id, Name = editModel.Name, FirstName = editModel.FirstName, DateOfBirth = editModel.DateOfBirth }; _context.Update(actor); _context.SaveChanges(); } catch (DbUpdateException) { if (!ActorExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(editModel)); }
public async Task <IActionResult> Edit(int id, [Bind("CineplexId,MovieId,SessionId")] CineplexMovie cineplexMovie) { if (id != cineplexMovie.CineplexId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cineplexMovie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CineplexMovieExists(cineplexMovie.CineplexId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["CineplexId"] = new SelectList(_context.Cineplex, "CineplexId", "Location", cineplexMovie.CineplexId); ViewData["MovieId"] = new SelectList(_context.Movie, "MovieId", "LongDescription", cineplexMovie.MovieId); ViewData["SessionId"] = new SelectList(_context.SessionMovie, "SessionId", "SessionId", cineplexMovie.SessionId); return(View(cineplexMovie)); }
public MovieDto UpdateMovie(MovieDto movieDto) { if (movieDto.Id == null) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } try { var movie = _mapper.Map <Movie>(movieDto); _context.Update(movie); _context.SaveChanges(); return(_mapper.Map <MovieDto>(movie)); } catch (DbUpdateException) { if (!MovieExists((int)movieDto.Id)) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } else { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } } }
public ActorDto UpdateActor(ActorDto actorDto) { if (actorDto.Id == null) { return(null); } try { var actor = _mapper.Map <Actor>(actorDto); _context.Update(actor); _context.SaveChanges(); return(_mapper.Map <ActorDto>(actor)); } catch (DbUpdateException) { if (!ActorExists((int)actorDto.Id)) { return(null); } return(null); } }
public IActionResult Edit(int id, [Bind("Id,Name,Surname,Birthdate")] EditActorViewModel editModel) { if (ModelState.IsValid) { try { var actor = _mapper.Map <EditActorViewModel, Actor>(editModel); actor.Id = id; _context.Update(actor); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ActorExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(editModel)); }
public ActorDto UpdateActor(ActorDto actorDto) { if (actorDto.Id == null) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } try { var actor = _mapper.Map <Actor>(actorDto); _context.Update(actor); _context.SaveChanges(); return(_mapper.Map <ActorDto>(actor)); } catch (DbUpdateException) { if (!ActorExists((int)actorDto.Id)) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } else { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,ReleaseDate,Genre,Price,Rating")] Movie movie) { if (id != movie.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,title,release")] Movies movies) { if (id != movies.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MoviesExists(movies.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movies)); }
public async Task <IActionResult> Edit(int id, [Bind("CineplexId,ImageUrl,Location,LongDescription,ShortDescription")] Cineplex cineplex) { if (id != cineplex.CineplexId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cineplex); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CineplexExists(cineplex.CineplexId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(cineplex)); }
public Movie UpdateMovie(Movie movietoUpdate) { if (movietoUpdate == null) { throw new ArgumentNullException(nameof(movietoUpdate)); } _context.Update(movietoUpdate); return(movietoUpdate); }
public IActionResult UpdateMovie(MoviesDb newMovie) { MoviesDb oldMovie = _context.MoviesDb.Find(newMovie.Id); if (ModelState.IsValid) { oldMovie.Title = newMovie.Title; oldMovie.Genre = newMovie.Genre; oldMovie.ReleaseYear = newMovie.ReleaseYear; oldMovie.RunTime = newMovie.RunTime; oldMovie.RentPrice = newMovie.RentPrice; _context.Entry(oldMovie).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(oldMovie); _context.SaveChanges(); } return(RedirectToAction("ListMovies")); }
public bool Attach(int actorId, int movieId) { try { var item = new MoviesActors { ActorId = actorId, MovieId = movieId }; _context.Update(item); _context.SaveChanges(); } catch (DbUpdateException) { return(false); } return(true); }
public IActionResult UpdateActor(int id, EditActorViewModel editModel) { try { var actor = _mapper.Map <Actor>(editModel); actor.Id = id; _context.Update(actor); _context.SaveChanges(); return(Ok(_mapper.Map <EditActorViewModel>(actor))); } catch (DbUpdateException) { if (!ActorExists(id)) { return(BadRequest()); } else { throw; } } }
[HttpPut("{id}")] // PUT: api/movies/5 public IActionResult UpdateMovie(int id, EditMovieViewModel editModel) { try { var movie = _mapper.Map <Movie>(editModel); movie.Id = id; _context.Update(movie); _context.SaveChanges(); return(Ok(_mapper.Map <EditMovieViewModel>(movie))); } catch (DbUpdateException) { if (!MovieExists(id)) { return(BadRequest()); } else { throw; } } }
public void UpdateRating(Rating r) { context.Update(r); context.SaveChanges(); }
public void Update(Peliculas pelicula) { _listaPeliculas.Update(pelicula); _listaPeliculas.SaveChanges(); }