コード例 #1
0
        public IActionResult FilmDetail(int id)
        {
            //ALLE STATUSSEN VAN 1 FILM
            IEnumerable <UserFilmGezienStatus> statuses =
                _DbContext.UserFilmGezienStatuses
                .Include(userFilmGezienStatus => userFilmGezienStatus.GezienStatus)
                .Where(userFilmGezienStatus => userFilmGezienStatus.FilmId == id).ToList();
            //
            int gezien  = 0;
            int wilZien = 0;

            foreach (var status in statuses)
            {
                if (status.GezienStatus.Id == 3)
                {
                    wilZien++;
                }
                if (status.GezienStatus.Id == 2)
                {
                    gezien++;
                }
            }

            Film filmFromDb = _DbContext.Films.
                              Include(a => a.Ratings).
                              FirstOrDefault(a => a.Id == id);

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            //VOOR REVIEW VAN 1 GEBRUIKER TE ZIEN
            //var review = filmFromDb.Ratings.FirstOrDefault(a => a.FilmId == filmFromDb.Id && a.UserId == userId);
            //
            List <string> reviews = new List <string>();
            List <int>    scores  = new List <int>();

            var review = filmFromDb.Ratings.Where(a => a.FilmId == filmFromDb.Id).ToList();

            foreach (var item in review)
            {
                reviews.Add(item.Review);
                scores.Add(item.Score);
            }

            FilmDetailViewModel film = new FilmDetailViewModel()
            {
                Titel      = filmFromDb.Titel,
                Regisseur  = filmFromDb.Regisseur,
                Reviews    = reviews,
                Scores     = scores,
                Foto       = filmFromDb.Foto,
                Gezien     = gezien,
                WillenZien = wilZien
            };

            return(View(film));
        }
コード例 #2
0
ファイル: FilmController.cs プロジェクト: Articfowl/MediaWeb
        public IActionResult AddItem(FilmDetailViewModel model)
        {
            int    id      = int.Parse(model.PlaylistId);
            int    movieId = model.Id;
            string type    = "Fi";

            _context.UserFilmPlaylist.Add(new UserFilmPlaylist()
            {
                FilmId = movieId, PlaylistId = id, UserId = _userManager.GetUserId(User)
            });
            _context.SaveChanges();
            return(RedirectToAction("Detail", "User", new { id, type }));
        }
コード例 #3
0
        public FilmDetailPage()
        {
            InitializeComponent();

            var film = new Film
            {
                Title       = "Film 1",
                Description = "This is an film description."
            };

            viewModel      = new FilmDetailViewModel(film);
            BindingContext = viewModel;
        }
コード例 #4
0
        public async Task <IActionResult> Detail(int id)
        {
            Film filmFromDb = await _mediaDbContext.Films.FindAsync(id);

            FilmDetailViewModel model = new FilmDetailViewModel
            {
                Id          = filmFromDb.Id,
                Producer    = filmFromDb.Producer,
                ReleaseDate = filmFromDb.ReleaseDate,
                Title       = filmFromDb.Title,
                Url         = filmFromDb.Url
            };

            return(View(model));
        }
コード例 #5
0
        public IActionResult Details(int id)
        {
            FilmDetailViewModel model = new FilmDetailViewModel();
            Film filmFromDb           = _context.Films.Include(film => film.Reviews).Include(reg => reg.Regisseurs).Include(genre => genre.Genres).FirstOrDefault(x => x.Id == id);

            model.Id           = filmFromDb.Id;
            model.Titel        = filmFromDb.Titel;
            model.Beschrijving = filmFromDb.Beschrijving;
            model.Speelduur    = filmFromDb.Speelduur;
            model.Foto         = filmFromDb.Foto;
            foreach (var item in filmFromDb.Regisseurs)
            {
                model.Regisseurs.Add(_context.Regisseurs.FirstOrDefault(x => x.Id == item.RegisseurId).Naam);
            }
            foreach (var item in filmFromDb.Genres)
            {
                model.Genres.Add(_context.GenreFilms.FirstOrDefault(y => y.Id == item.GenreId).Genrenaam);
            }
            //model.Reviews = filmFromDb.Reviews.ToList();
            return(View(model));
        }
コード例 #6
0
        public async Task <IActionResult> Detail(int id)
        {
            // Create a default View Model
            FilmDetailViewModel model = new FilmDetailViewModel();

            try
            {
                // Get the API data response from Repository
                var dataResponse = await _dataRepository.GetFilmDetailsAsync(id);

                // Populate view model with films in release year order - if response is ok
                if (dataResponse.StatusCode == HttpStatusCode.OK)
                {
                    var filmData = dataResponse.ApiData;

                    // Map incoming data to View Model - could do this manually by assigning each property but quicker to use mapper plugin and then assign specific props as reqd.
                    model = Mapper.Map(filmData).ToANew <FilmDetailViewModel>();

                    model.PageHeader      = $"Details for: {model.Title}";
                    model.PlanetsCount    = filmData.Planets.Count;
                    model.StarshipsCount  = filmData.Starships.Count;
                    model.CharactersCount = filmData.Characters.Count;
                }
                else
                {
                    model.PageHeader = "Film Details not Found";
                }
            }
            catch (Exception ex)
            {
                model.PageHeader = $"An error has occurred: {ex.Message}";

                // Log the error here - not implemented in this test.
            }

            return(View(model));
        }
コード例 #7
0
ファイル: FilmController.cs プロジェクト: Articfowl/MediaWeb
        public IActionResult Detail(int Id)
        {
            string Userid = _userManager.GetUserId(User);
            List <FilmPlaylist> filmPlaylists = _context.FilmPlaylist.Where(fp => fp.UserId == _userManager.GetUserId(User)).ToList();
            Film filmFromDb = _context.Film.Include(f => f.Favourites).Include(f => f.FilmGezienStatuses).Include(f => f.Genres)
                              .Include(f => f.Regisseurs).FirstOrDefault(x => x.Id == Id);

            //Als film niet zichtbaar is en user is geen admin redirecten naar index;
            if (!filmFromDb.Zichtbaar && !User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index"));
            }
            FilmDetailViewModel myModel = new FilmDetailViewModel()
            {
                Id               = filmFromDb.Id,
                FilmArt          = filmFromDb.Foto,
                AantalFavoriet   = filmFromDb.Favourites.Count,
                Titel            = filmFromDb.Titel,
                AantalGezien     = 0,
                GezienStatusList = _statusItemList,
                Beschrijving     = filmFromDb.Beschrijving,
                UserPlaylists    = new List <SelectListItem>()
            };
            //Favoriet + user checken.
            UserFilmFavourite UFF = filmFromDb.Favourites.FirstOrDefault(x => x.UserId == Userid && x.FilmId == Id);

            if (UFF != null)
            {
                myModel.Favoriet = true;
            }
            //Gezienstatus+ user checken.
            UserFilmGezienStatus UFG = _context.UserFilmGezienStatus.FirstOrDefault(x => x.UserId == _userManager.GetUserId(User) && x.FilmId == Id);

            if (UFG != null)
            {
                myModel.GezienStatusList[UFG.StatusId - 1].Selected = true;
            }
            foreach (var item in filmFromDb.FilmGezienStatuses)
            {
                if (item.StatusId == 3)
                {
                    myModel.AantalGezien++;
                }
            }
            //Genres toevoegen
            foreach (var genre in filmFromDb.Genres)
            {
                myModel.Genres.Add(_context.FilmGenre.FirstOrDefault(fg => fg.Id == genre.GenreId).Genre);
            }
            //Regisseurs toevoegen
            foreach (var regi in filmFromDb.Regisseurs)
            {
                myModel.Regisseurs.Add(_context.FilmRegisseur.FirstOrDefault(fr => fr.Id == regi.RegisseurId).Naam);
            }
            //Playlists toevoegen
            foreach (var item in filmPlaylists)
            {
                if (!_context.UserFilmPlaylist.Any(ufp => ufp.FilmId == Id && ufp.PlaylistId == item.Id))
                {
                    myModel.UserPlaylists.Add(new SelectListItem(item.Titel, item.Id.ToString()));
                }
            }
            return(View(myModel));
        }
コード例 #8
0
        public FilmDetailPage(FilmDetailViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.viewModel = viewModel;
        }
コード例 #9
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     _filmDetailViewModel = DataContext as FilmDetailViewModel;
 }
コード例 #10
0
 public FilmDetailView(FilmDetailViewModel model)
 {
     InitializeComponent();
     Model       = model;
     DataContext = Model;
 }