Пример #1
0
        public IActionResult Index(int id)  //Album.Id passed in
        {
            var artistAlbumInfoModel = _albumSong.GetAlbumByAlbum(id);
            var songModel            = _albumSong.GetAllSongsByAlbum(id);

            var album = new AlbumListingModel
            {
                Id           = artistAlbumInfoModel.Album.Id,
                Name         = artistAlbumInfoModel.Album.Name,
                YrReleased   = artistAlbumInfoModel.Album.YrReleased,
                PrimaryImage = _image.GetPrimaryImageByEntity(1, artistAlbumInfoModel.Album.Id, 1)
            };

            var artistInfo = new ArtistListingModel
            {
                Id           = artistAlbumInfoModel.Artist.Id,
                ArtistName   = artistAlbumInfoModel.Artist.ArtistName,
                Bio          = artistAlbumInfoModel.Artist.Bio,
                YrFormed     = artistAlbumInfoModel.Artist.YrFormed,
                YrEnded      = artistAlbumInfoModel.Artist.YrEnded,
                isActive     = artistAlbumInfoModel.Artist.isActive,
                HomeCountry  = artistAlbumInfoModel.Artist.HomeCountry,
                HomeTown     = artistAlbumInfoModel.Artist.HomeTown,
                PrimaryImage = _image.GetPrimaryImageByEntity(2, artistAlbumInfoModel.Artist.Id, 2)
            };

            var songs = songModel.Select
                            (r => new SongListingModel
            {
                Id          = r.Song.Id,
                Name        = r.Song.Name,
                Duration    = r.Song.Duration,
                TrackNumber = r.TrackNumber
                              //PrimaryImage = _image.GetPrimaryImageByEntity(1, r.Album.Id, 1)
            }
                            ).ToList();

            var model = new AlbumInfoIndexModel
            {
                Artist = artistInfo,
                Album  = album,
                Songs  = songs
            };

            return(View(model));
        }
Пример #2
0
        public IActionResult Index(int albumId, int artistId) //artistId always passed, albumId optional
        {
            var artistModel   = _artist.Get(artistId);
            var albumModel    = _albumSong.GetAllAlbumsByArtist(artistId).FirstOrDefault(); //return 1, may be 0, 1, or M.
            var songModel     = _albumSong.GetRandomSongsByArtist(artistId);                //may be 0, 1, or M.
            var allSongsModel = _albumSong.GetAllSongsByArtist(artistId);

            //var artistAlbumInfoModel = _albumSong.GetAlbumByAlbum(albumId);
            //var songModel = _albumSong.GetAllSongsByAlbum(albumId);
            if (albumId != 0)
            {
                albumModel = _albumSong.GetAlbumByAlbum(albumId);
                songModel  = _albumSong.GetAllSongsByAlbum(albumId);
            }

            //empty song object - bind to form
            var song = new SongListingModel
            {
                Id          = 0,
                Name        = string.Empty,
                Duration    = string.Empty,
                TrackNumber = 0
            };

            //all existing songs on album, if any
            var songs = songModel.Select
                            (r => new SongListingModel
            {
                Id          = r.Song.Id,
                Name        = r.Song.Name,
                Duration    = r.Song.Duration,
                TrackNumber = r.TrackNumber
                              //PrimaryImage = _image.GetPrimaryImageByEntity(1, r.Album.Id, 1)
            }
                            ).ToList();

            var album = new AlbumListingModel
            {
                Id           = albumModel.Album.Id,
                Name         = albumModel.Album.Name,
                YrReleased   = albumModel.Album.YrReleased,
                PrimaryImage = _image.GetPrimaryImageByEntity(1, albumModel.Album.Id, 1)
            };

            var artistInfo = new ArtistListingModel
            {
                Id           = artistModel.Id,
                ArtistName   = artistModel.ArtistName,
                Bio          = artistModel.Bio,
                YrFormed     = artistModel.YrFormed,
                YrEnded      = artistModel.YrEnded,
                isActive     = artistModel.isActive,
                HomeCountry  = artistModel.HomeCountry,
                HomeTown     = artistModel.HomeTown,
                PrimaryImage = _image.GetPrimaryImageByEntity(2, artistModel.Id, 2)
            };

            var model = new SongPostIndexModel
            {
                Artist = artistInfo,
                Album  = album,
                Songs  = songs,
                Song   = song
            };

            return(View(model));
        }