Exemple #1
0
        public ActionResult GetActorsOfMovie(Guid id)
        {
            var listActorIds           = _actorMovieService.GetIdActorByMovieId(id);
            ICollection <Actor> actors = new List <Actor>();

            foreach (var actorId in listActorIds)
            {
                Actor actor = _actorsService.Find(actorId);
                if (actor != null)
                {
                    actors.Add(actor);
                }
            }

            var actorViewModels = AutoMapper.Mapper.Map <IEnumerable <ActorViewModel> >(actors);

            return(PartialView("_ActorsOfMovie", actorViewModels));
        }
Exemple #2
0
        public ActionResult Edit(Guid id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            var film = _filmService.Find(id);

            if (film == null)
            {
                return(HttpNotFound());
            }
            var movie = _movieService.Find(film.MovieId);

            var movieViewModel = AutoMapper.Mapper.Map <MoviesViewModel>(movie);
            var filmViewModel  = AutoMapper.Mapper.Map <FilmViewModel>(film);

            //Director Start
            var listDirectorMovie  = _directorMovieService.GetIdDirectorByMovieId(movie.Id);
            var listDirector       = _directorService.GetAll();
            var listDirectorSelect = new List <SelectListItem>();

            foreach (var item in listDirector)
            {
                if (listDirectorMovie.Contains(item.Id))
                {
                    listDirectorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameDirector,
                        Selected = true
                    });
                }
                else
                {
                    listDirectorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameDirector,
                        Selected = false
                    });
                }
            }
            //Director End

            //Actor Start
            var listActorMovie  = _actorMovieService.GetIdActorByMovieId(movie.Id);
            var listActor       = _actorService.GetAll();
            var listActorSelect = new List <SelectListItem>();

            foreach (var item in listActor)
            {
                if (listActorMovie.Contains(item.Id))
                {
                    listActorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameActor,
                        Selected = true
                    });
                }
                else
                {
                    listActorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameActor,
                        Selected = false
                    });
                }
            }
            //Actor End

            //Producer Start
            var listProducerMovie  = _producerMovieService.GetIdProducerByMovieId(movie.Id);
            var listProducer       = _producerService.GetAll();
            var listProducerSelect = new List <SelectListItem>();

            foreach (var item in listProducer)
            {
                if (listProducerMovie.Contains(item.Id))
                {
                    listProducerSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameProducer,
                        Selected = true
                    });
                }
                else
                {
                    listProducerSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameProducer,
                        Selected = false
                    });
                }
            }
            //Producer End

            //Category Start
            var listCategoryMovie  = _categoryMovieService.GetIdCategoryByMovieId(movie.Id);
            var listCategory       = _categorysService.GetAll();
            var listCategorySelect = new List <SelectListItem>();

            foreach (var item in listCategory)
            {
                if (listCategoryMovie.Contains(item.Id))
                {
                    listCategorySelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameCategory,
                        Selected = true
                    });
                }
                else
                {
                    listCategorySelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameCategory,
                        Selected = false
                    });
                }
            }
            //Category End

            //Resolution Start
            var listResolutionMovie  = _resolutionMovieService.GetIdResolutionByMovieId(movie.Id);
            var listResolution       = _resolutionService.GetAll();
            var listResolutionSelect = new List <SelectListItem>();

            foreach (var item in listResolution)
            {
                if (listResolutionMovie.Contains(item.Id))
                {
                    listResolutionSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameResolution,
                        Selected = true
                    });
                }
                else
                {
                    listResolutionSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameResolution,
                        Selected = false
                    });
                }
            }
            //Resolution End

            //Tag Start
            var listTagMovie  = _tagMovieService.GetIdTagByMovieId(movie.Id);
            var listTag       = _tagService.GetAll();
            var listTagSelect = new List <SelectListItem>();

            foreach (var item in listTag)
            {
                if (listResolutionMovie.Contains(item.Id))
                {
                    listTagSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameTag,
                        Selected = true
                    });
                }
                else
                {
                    listTagSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameTag,
                        Selected = false
                    });
                }
            }
            //Tag End


            ViewBag.ListDirector   = listDirectorSelect;
            ViewBag.ListActor      = listActorSelect;
            ViewBag.ListProducer   = listProducerSelect;
            ViewBag.ListCategory   = listCategorySelect;
            ViewBag.ListResolution = listResolutionSelect;
            ViewBag.ListTag        = listTagSelect;


            var model = new FeatureFilmViewModel()
            {
                MoviesViewModel = movieViewModel,
                FilmViewModel   = filmViewModel
            };

            return(View("_Edit", model));
        }