Esempio n. 1
0
        public ActionResult EditFilm(ViewModelEditFilm viewModelEditFilm)
        {
            var selectedGenres = _filmModels.GetAllGenres().Where(p => viewModelEditFilm.SelectedGenres.Contains(p.GenreID));
            var completeFilm   = viewModelEditFilm.Film;

            completeFilm.Genres = new System.Collections.Generic.List <Genre>();
            completeFilm.Genres.AddRange(selectedGenres);
            _filmModels.EditFilm(completeFilm);

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult EditFilm(int id)
        {
            var genres = _filmModels.GetAllGenres().ToDictionary(genre => genre.Title, genre => genre.GenreID);

            var film = _filmModels.GetFilmById(id);

            var selectedGenres = film.Genres.Select(p => p.GenreID).ToList();

            var viewModelEditFilm = new ViewModelEditFilm
            {
                Film           = film,
                Genres         = genres,
                SelectedGenres = selectedGenres
            };

            return(View(viewModelEditFilm));
        }