public async Task <IActionResult> Edit(int id, [Bind("Id,Full_name")] Actor actor) { if (id != actor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(actor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActorExists(actor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(actor)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Ru_name,Year,Tagline,Description,Poster,Age_rating,KP_rate,IMDB_rate")] Film film, int[] genreId, int[] actorId) { if (id != film.Id) { return(NotFound()); } film.Genres.Clear(); if (genreId != null) { foreach (var g in _context.Genres.Where(genre => genreId.Contains(genre.Id))) { film.Genres.Add(g); } } film.Actors.Clear(); if (actorId != null) { foreach (var a in _context.Actors.Where(actor => actorId.Contains(actor.Id))) { film.Actors.Add(a); } } if (ModelState.IsValid) { try { _context.Update(film); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FilmExists(film.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(film)); }