Beispiel #1
0
        public ActionResult <Film> PostFilm(Film film)
        {
            _filmRepo.Create(film);
            _filmRepo.Save();

            return(CreatedAtAction("GetFilm", new { id = film.Id }, film));
        }
Beispiel #2
0
        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)));
        }