コード例 #1
0
        public IActionResult Index()
        {
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);
            // selects non approved media
            var MediaList = _mediaService.GetAllMedia().Where(m => m.IsPublic != true);

            // maps to listviewmodel
            var mediaListViewModel = new List <MediaListViewModel>();

            foreach (var med in MediaList)
            {
                var model =
                    new MediaListViewModel()
                {
                    Id                   = med.Id,
                    Photo                = med.Photo,
                    Titel                = med.Titel,
                    IsChecked            = false,
                    AddedByMediaUserName = med.MediaUser.UserName
                };

                mediaListViewModel.Add(model);
            }
            var MediaOverviewVM = new MediaOverviewViewModel()
            {
                UnApprovedMediaList = mediaListViewModel
            };


            return(View(MediaOverviewVM));
        }
コード例 #2
0
        public IActionResult Details(int id)
        {
            //var isSignedIn = this._signinManager.IsSignedIn(HttpContext.User);
            //var currentUserId = this._signinManager.UserManager.GetUserId(HttpContext.User);
            //if (isSignedIn)
            //{
            //    _currentMediaUser = _mediaService.GetAllMediaUseren().First(p => p.Id == currentUserId);
            //}
            Podcast selectedPodcast = _mediaService.GetAllPodcasts().FirstOrDefault(x => x.Id == id);

            var     UserRatingList    = _mediaService.GetAllRatings().Where(pod => pod.Media.Id == selectedPodcast.Id);
            Podcast podcast           = _mediaService.GetAllPodcasts().First(x => x.Id == id);
            var     media             = _mediaService.GetAllMedia().First(med => med.Titel == podcast.Titel);
            PodcastDetailViewModel vm = new PodcastDetailViewModel()
            {
                MediaId     = id,
                Name        = podcast.Name,
                Photo       = podcast.Photo,
                PodcastLink = podcast.ConversationMP3,
                IsRated     = UserRatingList.Count() > 0? true :false,
                IsSignedIn  = false//currentUserId == null ? false : true,
            };

            vm.AveragePoints = selectedPodcast.Ratings.Count() > 0 ? selectedPodcast.Ratings.Average(r => r.Points) : 0;
            vm.PlayLists     = new List <PlayList>();
            if (_currentMediaUser != null)
            {
                vm.PlayLists = _currentMediaUser.Playlists.ToList();
            }
            return(View(vm));
        }
コード例 #3
0
        public IActionResult AddToPlaylist(PlayListAddMediaViewModel playListAddMediaViewModel)
        {
            if (playListAddMediaViewModel.PlayListId == 0)
            {
                return(View("Index"));
            }
            var playList = _mediaService.GetAllPlaylists().First(pl => pl.Id == playListAddMediaViewModel.PlayListId);
            var media    = _mediaService.GetAllMedia().First(m => m.Id == playListAddMediaViewModel.MediaId);

            playList.MediaList.Add(media);
            _mediaService.SaveChanges();

            return(RedirectToAction("Details", new { id = playList.Id }));
        }
コード例 #4
0
        public IActionResult Index()
        {
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);
            var user          = _mediaService.GetAllMediaUsers().Where(prof => prof.Id == currentUserId).FirstOrDefault();
            var media         = _mediaService.GetAllMedia().OfType <Movie>().Take(10);
            var topMovies     = _mediaService.GetAllMedia().OfType <Movie>().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings)*/;
            var topSeries     = _mediaService.GetAllSeries().Take(10).Where(m => m.IsPublic == true);
            var topMusic      = _mediaService.GetAllMedia().OfType <Music>().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings) */;
            var topPodcasts   = _mediaService.GetAllPodcasts().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings)*/;
            var topPlaylists  = _mediaService.GetAllPlaylists().Take(10).Where(m => m.MediaUser == _currentMediaUser);

            var vm = new HomeOverviewViewModel
            {
                Movies     = topMovies,
                Series     = topSeries,
                Musics     = topMusic,
                Podcasts   = topPodcasts,
                PlayLists  = topPlaylists,
                IsSignedIn = true, //isSignedIn,
                MediaUser  = user  //_currentMediaUser
            };

            return(View(vm));
        }
コード例 #5
0
        public IActionResult Index()
        {
            // create list songs view
            List <MusicListViewModel> Songs          = new List <MusicListViewModel>();
            IEnumerable <Music>?      songListFromDb = _mediaService.GetAllMedia().OfType <Music>();

            if (songListFromDb.Count() > 0)
            {
                foreach (var song in songListFromDb)
                {
                    Songs.Add(new MusicListViewModel()
                    {
                        Id = song.Id, ZangersName = song.ZangersName, Titel = song.Titel, Photo = song.Photo
                    });
                }
            }

            return(View(Songs));
        }
コード例 #6
0
        public IActionResult Index()
        {
            List <MovieListViewModel> Movies          = new List <MovieListViewModel>();
            IEnumerable <Movie>?      movieListFromDb = _mediaService.GetAllMedia().OfType <Movie>();

            if (movieListFromDb.Any() && movieListFromDb != null)
            {
                foreach (var movie in movieListFromDb)
                {
                    Movies.Add(new MovieListViewModel()
                    {
                        Id          = movie.Id,
                        Titel       = movie.Titel,
                        Duration    = movie.Duration,
                        IMDBLink    = movie.IMDBLink,
                        Photo       = movie.Photo,
                        ReleaseDate = movie.ReleaseDate,
                    });;
                }
            }

            return(View(Movies));
        }