コード例 #1
0
        private void addTracks(AlbumModel album)
        {
            List <TrackModel> tracks = _sourceManagerEF.GetTracks();
            int id = 0;

            if (tracks != null && tracks.Count != 0)
            {
                foreach (var track in tracks)
                {
                    track.Album    = new AlbumModel();
                    track.Album.ID = album.ID;
                    _context.Tracks.Add(track);
                    _context.SaveChanges();

                    int trackId = _context.Tracks.Where(t => t.Album.ID == album.ID && t.Title == track.Title).SingleOrDefault().ID;

                    List <ExtraArtistModel> xartists = _sourceManagerEF.GetExtraArtist(id);
                    if (xartists != null && xartists.Count != 0)
                    {
                        foreach (var xartist in xartists)
                        {
                            xartist.Track    = new TrackModel();
                            xartist.Track.ID = trackId;
                            _context.ExtraArtists.Add(xartist);
                            //_context.SaveChanges();
                        }
                    }
                    id++;
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> GetMyAlbum(string link)
        {
            UserModel user = await _userManager.GetUserAsync(User);

            AlbumModel album = _sourceManagerEF.Load(link).GetAlbum();

            album.User    = user;
            album.Tracks  = _sourceManagerEF.GetTracks();
            album.Images  = _sourceManagerEF.GetImages();
            album.Videos  = _sourceManagerEF.GetVideos();
            album.Genres  = _sourceManagerEF.GetGenres();
            album.Styles  = _sourceManagerEF.GetStyles();
            album.Artists = _sourceManagerEF.GetArtist();
            AlbumThumbModel albumThumb = _sourceManagerEF.GetAlbumThumb();

            albumThumb.User  = user;
            album.AlbumThumb = albumThumb;

            _context.Albums.Add(album);

            var result = _context.SaveChanges();

            return(Ok());
        }