private void addImages(AlbumModel album)
        {
            List <ImageModel> images = _sourceManagerEF.GetImages();

            if (images != null && images.Count != 0)
            {
                foreach (var image in images)
                {
                    image.Album    = new AlbumModel();
                    image.Album.ID = album.ID;
                    _context.Images.Add(image);
                    _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());
        }