public async Task <IActionResult> Create([Bind("Id,Name,Ru_name,Year,Tagline,Description,Poster,Age_rating,KP_rate,IMDB_rate")] Film film, int[] genreId, int[] actorId) { 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) { _context.Add(film); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(film)); }
public async Task <IActionResult> Create([Bind("Id,Full_name")] Actor actor) { if (ModelState.IsValid) { _context.Add(actor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(actor)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Genre genre) { if (ModelState.IsValid) { _context.Add(genre); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(genre)); }