public IActionResult PutFilm(int id, Film film) { if (id != film.Id) { return(BadRequest()); } try { _filmRepo.Update(film); _filmRepo.Save(); } catch (DbUpdateConcurrencyException) { if (!FilmExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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))); }