public async Task <IActionResult> EditAsync(int id, [Bind("Id,Name,ArtistName,Length,ReleaseDate,TrackNumber,Publisher,AlbumId")] Song song)
        {
            ApplicationUser currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            if (id != song.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //ApplicationUser user = await _userManager.FindByNameAsync(User.Identity.Name);

                    song.ArtistId = currentUser.Id;
                    song.Artist   = currentUser;

                    _context.Update(song);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SongExists(song.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = id }));
            }

            ViewData["AlbumId"] = (IEnumerable <SelectListItem>)BuildUserAlbumsDropDownList(currentUser);
            return(View(song));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Publisher,Id,ArtistId,Name,ArtistName,ReleaseDate")] Album album)
        {
            ApplicationUser currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            if (currentUser == null)
            {
                throw new Exception("Current user not found.");
            }

            album.ArtistId = currentUser.Id;
            album.Artist   = currentUser;

            if (id != album.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(album);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlbumExists(album.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            //ViewData["ArtistId"] = new SelectList(_context.Users, "Id", "Id", album.ArtistId);
            return(View(album));
        }