public ActionResult <Film> PostFilm(Film film) { _filmRepo.Create(film); _filmRepo.Save(); return(CreatedAtAction("GetFilm", new { id = film.Id }, film)); }
public IActionResult Create(FilmEditViewModel filmEditViewModel) { if (!ModelState.IsValid) { return(View(filmEditViewModel)); } var film = _mapper.Map <Film>(filmEditViewModel); filmEditViewModel.GenreViewModels.RemoveAll(gs => !gs.Checked); film.FilmGenres = _mapper.Map <FilmEditViewModel, List <FilmGenre> >(filmEditViewModel); _filmRepo.Create(film); _filmRepo.Save(); return(RedirectToAction(nameof(Index))); }