private void addGenres(AlbumModel album)
        {
            List <GenreModel> genres = _sourceManagerEF.GetGenres();

            if (genres != null && genres.Count != 0)
            {
                foreach (var genre in genres)
                {
                    genre.Album    = new AlbumModel();
                    genre.Album.ID = album.ID;
                    _context.Genres.Add(genre);
                    //_context.SaveChanges();
                }
            }
        }
示例#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());
        }