Example #1
0
        public async Task <IActionResult> Detail(int id)
        {
            Song songFromDb =
                await _mediaWebDbContext.Songs
                .Include(song => song.SongArtists)
                .ThenInclude(songArtist => songArtist.Artist)
                .Include(song => song.SongReviews)
                .ThenInclude(songReviews => songReviews.Review)
                .ThenInclude(review => review.MediaWebUser)
                .FirstOrDefaultAsync(s => s.Id == id);

            var user = _userManager.GetUserAsync(HttpContext.User).Result;

            MusicDetailViewModel detailModel = new MusicDetailViewModel()
            {
                Id          = songFromDb.Id,
                Title       = songFromDb.Title,
                ReleaseDate = songFromDb.ReleaseDate,
                SongFile    = songFromDb.SongFile,
                SongArtists = songFromDb.SongArtists,
                SongReviews = songFromDb.SongReviews.Where(sr => sr.Review.IsChecked == true),
                IsHidden    = songFromDb.IsHidden,
                MyPlaylists = await _mediaWebDbContext.PlayLists.Where(pl => pl.MediaWebUser == user).ToListAsync()
            };

            return(View(detailModel));
        }
        public async Task <IActionResult> Detail(int id)
        {
            Film filmFromDb = await _mediaDbContext.Films.FindAsync(id);

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

            return(View(model));
        }
        public async Task <IActionResult> Detail(int id, bool alreadyReviewed = false)
        {
            var song = await _songService.FindSongByIdDetailed(id);

            var approvedReviews = new List <SongReviewViewModel>();

            var vm = new MusicDetailViewModel
            {
                Id = song.Id,
                AlreadyReviewed = alreadyReviewed,
                SongTitle       = song.Title,
                AlbumTitle      = song.Album?.Title,
                BandName        = song.Album?.Band?.Name,
                Duration        = song.Duration,
                ReleaseDate     = song.Album?.ReleaseDate,
                Link            = song.SongLink,
                PhotoUrl        = song.Album?.PhotoUrl
            };

            foreach (var item in song.SongReviews)
            {
                if (item.Approved)
                {
                    approvedReviews.Add(new SongReviewViewModel
                    {
                        Description = item.Description,
                        Score       = item.Score,
                        User        = item.User.UserName,
                        Id          = item.Id,
                        Approved    = true,
                    });
                }
                else
                {
                    approvedReviews.Add(new SongReviewViewModel
                    {
                        Description = item.Description,
                        Score       = item.Score,
                        User        = item.User.UserName,
                        Id          = item.Id,
                        Approved    = false,
                    });
                }
            }

            vm.Reviews = approvedReviews;

            return(View(vm));
        }
        public IActionResult Details(int id)
        {
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);

            _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId);

            Music         selectedMusic  = _mediaService.GetAllMedia().OfType <Music>().Where(muz => muz.Id == id).FirstOrDefault();
            List <Rating> UserRatingList = new List <Rating>();
            bool          isAlreadyRated = false;
            var           playlists      = new List <PlayList>();

            if (_currentMediaUser != null)
            {
                isAlreadyRated = _mediaService.GetAllRatings().Where(movie => movie.Media.Titel == selectedMusic.Titel).Where(user => user.MediaUser.Id == _currentMediaUser.Id).Any();
                playlists      = _currentMediaUser.Playlists.ToList();
            }

            UserRatingList = _mediaService.GetAllRatings().Where(music => music.Media.Id == selectedMusic.Id).ToList();
            var detailViewModel = new MusicDetailViewModel()
            {
                MediaId     = selectedMusic.Id,
                Lied        = selectedMusic.Lied,
                Titel       = selectedMusic.Titel,
                ZangersName = selectedMusic.ZangersName,
                Photo       = selectedMusic.Photo,
                IsRated     = isAlreadyRated,
                PlayLists   = playlists,
                IsSignedIn  = true
            };

            if (selectedMusic.Ratings.Count() > 0)
            {
                detailViewModel.AveragePoints = selectedMusic.Ratings.Where(med => med.Media.Id == selectedMusic.Id) != null?selectedMusic.Ratings.Where(med => med.Media.Id == selectedMusic.Id).Average(r => r.Points) : 0;
            }
            if (_currentMediaUser != null)
            {
                detailViewModel.PlayLists = _currentMediaUser.Playlists.ToList();
            }
            return(View(detailViewModel));
        }
Example #5
0
        public IActionResult ArtistDetail(int id)
        {
            Artist artist = _appContext.Artists.FirstOrDefault(x => x.Id == id);
            IEnumerable <Album> albums = _appContext.Albums.Where(a => a.Artist == artist);
            IEnumerable <Songs> songs  = _appContext.Songs.Where(s => s.Artist == artist);

            List <string> albumTitles      = new List <string>();
            List <string> songTitles       = new List <string>();
            List <MusicDetailViewModel> vm = new List <MusicDetailViewModel>();


            MusicDetailViewModel musicDetail = new MusicDetailViewModel()
            {
                ArtistName = artist.Naam,
                Albums     = albums.ToArray(),
                Songs      = songs.ToArray()
            };

            vm.Add(musicDetail);


            return(View(musicDetail));
        }
        // GET: Musics/Details/5
        public IActionResult Details(int?id)
        {
            var music = _context.Musics.Include(m => m.Reviews).Include(m => m.Genres).Include(m => m.Writers).FirstOrDefault(m => m.ID == id);
            List <MusicReviewViewModel>   Reviews   = new List <MusicReviewViewModel>();
            List <MusicGenreViewModel>    genres    = new List <MusicGenreViewModel>();
            List <MusicDirectorViewModel> directors = new List <MusicDirectorViewModel>();
            List <MusicWriterViewModel>   writers   = new List <MusicWriterViewModel>();

            foreach (var review in music.Reviews)
            {
                Reviews.Add(new MusicReviewViewModel()
                {
                    Comment = review.Comment,
                    ID      = review.ID,
                    MusicID = review.MusicsID,
                    Rating  = review.Rating,
                });
            }
            foreach (var genre in music.Genres)
            {
                genres.Add(new MusicGenreViewModel()
                {
                    Naam = genre.Naam
                });
            }
            foreach (var writer in music.Writers)
            {
                writers.Add(new MusicWriterViewModel()
                {
                    ID = writer.ID, Name = writer.Name, DateOfBirth = writer.DateOfBirth, Music = writer.Music.Titel
                });
            }
            var model = new MusicDetailViewModel()
            {
                ID           = music.ID,
                Titel        = music.Titel,
                ReleaseDate  = music.ReleaseDate,
                Lenght       = music.Lenght,
                Reviews      = Reviews,
                Genres       = genres,
                Directors    = directors,
                Writers      = writers,
                PhotoPath    = music.PhotoPath,
                Youtube      = music.YoutubeTrailer,
                Listened     = music.Listened,
                WantToListen = music.WantToListen,
            };

            foreach (var review in music.Reviews)
            {
                totalrating = totalrating + review.Rating;
                teller++;
            }
            if (teller != 0)
            {
                ViewBag.avg = avgrating = totalrating / teller;
            }
            if (music == null)
            {
                return(NotFound());
            }

            return(View(model));
        }